


from collections import OrderedDict
from typing import TYPE_CHECKING, Any, List, Mapping, Optional

from packaging import version


if TYPE_CHECKING:
   from ... import PreTrainedTokenizer, TensorType

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast, PatchingSpec
from ...utils import is_torch_available, logging


_A			=						logging.get_logger(__name__)

_A			=						{
    'bigscience/bloom': 'https://huggingface.co/bigscience/bloom/resolve/main/config.json',
    'bigscience/bloom-560m': 'https://huggingface.co/bigscience/bloom-560m/blob/main/config.json',
    'bigscience/bloom-1b1': 'https://huggingface.co/bigscience/bloom-1b1/blob/main/config.json',
    'bigscience/bloom-1b7': 'https://huggingface.co/bigscience/bloom-1b7/blob/main/config.json',
    'bigscience/bloom-3b': 'https://huggingface.co/bigscience/bloom-3b/blob/main/config.json',
    'bigscience/bloom-7b1': 'https://huggingface.co/bigscience/bloom-7b1/blob/main/config.json',
}






class    UpperCAmelCase__	( A_		):



    """simple docstring"""






    UpperCAmelCase__						:		List[str]              =  "bloom"
    UpperCAmelCase__						:		List[Any]              =  ["past_key_values"]
    UpperCAmelCase__						:		str              =  {
        "num_hidden_layers": "n_layer",
        "num_attention_heads": "n_head",
    }






    def __init__(      self ,       A_=250880 ,       A_=64 ,       A_=2 ,       A_=8 ,       A_=1E-5 ,       A_=0.02 ,       A_=True ,       A_=1 ,       A_=2 ,       A_=False ,       A_=0.0 ,       A_=0.0 ,       A_=1 ,       A_=False ,       **A_ ,       )  ->	Optional[int]:
         __UpperCamelCase   							=vocab_size
         # Backward compatibility with n_embed kwarg
         __UpperCamelCase   							=kwargs.pop('n_embed' ,       A_   )
         __UpperCamelCase   							=hidden_size if n_embed is None else n_embed
         __UpperCamelCase   							=n_layer
         __UpperCamelCase   							=n_head
         __UpperCamelCase   							=layer_norm_epsilon
         __UpperCamelCase   							=initializer_range
         __UpperCamelCase   							=use_cache
         __UpperCamelCase   							=pretraining_tp
         __UpperCamelCase   							=apply_residual_connection_post_layernorm
         __UpperCamelCase   							=hidden_dropout
         __UpperCamelCase   							=attention_dropout

         __UpperCamelCase   							=bos_token_id
         __UpperCamelCase   							=eos_token_id
         __UpperCamelCase   							=slow_but_exact

         super().__init__(bos_token_id=A_ ,       eos_token_id=A_ ,       **A_   )






class    UpperCAmelCase__	( A_		):



    """simple docstring"""






    UpperCAmelCase__						:		Tuple              =  version.parse("1.12"		)






    def __init__(      self ,       A_ ,       A_ = "default" ,       A_ = None ,       A_ = False ,       )  ->	Dict:
         super().__init__(A_ ,       task=A_ ,       patching_specs=A_ ,       use_past=A_   )
         if not getattr(self._config ,       'pad_token_id' ,       A_   ):
              # TODO: how to do that better?
              __UpperCamelCase   							=0






    @property
    def _a (      self   )  ->	Mapping[str, Mapping[int, str]]:
         __UpperCamelCase   							=OrderedDict({'input_ids': {0: 'batch', 1: 'sequence'}}   )
         if self.use_past:
              # BLOOM stores values on dynamic axis 2. For more details see: https://github.com/huggingface/transformers/pull/18344
              self.fill_with_past_key_values_(A_ ,       direction='inputs' ,       inverted_values_shape=A_   )
              __UpperCamelCase   							={0: 'batch', 1: 'past_sequence + sequence'}
         else:
              __UpperCamelCase   							={0: 'batch', 1: 'sequence'}

         return common_inputs






    @property
    def _a (      self   )  ->	int:
         return self._config.n_layer






    @property
    def _a (      self   )  ->	int:
         return self._config.n_head






    @property
    def _a (      self   )  ->	float:
         return 1E-3






    def _a (      self ,       A_ ,       A_ = -1 ,       A_ = -1 ,       A_ = False ,       A_ = None ,       )  ->	Mapping[str, Any]:
         __UpperCamelCase   							=super(A_ ,       self   ).generate_dummy_inputs(
             A_ ,       batch_size=A_ ,       seq_length=A_ ,       is_pair=A_ ,       framework=A_   )

         # We need to order the input in the way they appears in the forward()
         __UpperCamelCase   							=OrderedDict({'input_ids': common_inputs['input_ids']}   )

         # Need to add the past_keys
         if self.use_past:
              if not is_torch_available():
                   raise ValueError('Cannot generate dummy past_keys inputs without PyTorch installed.'   )
              else:
                   import torch

                   __UpperCamelCase							,				__UpperCamelCase   							=common_inputs['input_ids'].shape
                   # Not using the same length for past_key_values
                   __UpperCamelCase   							=seqlen + 2
                   __UpperCamelCase   							=self._config.hidden_size // self.num_attention_heads
                   __UpperCamelCase   							=(
                       batch * self.num_attention_heads,
                       head_dim,
                       past_key_values_length,
                   )
                   __UpperCamelCase   							=(
                       batch * self.num_attention_heads,
                       past_key_values_length,
                       head_dim,
                   )
                   __UpperCamelCase   							=[
                       (torch.zeros(A_   ), torch.zeros(A_   )) for _ in range(self.num_layers   )
                   ]

         __UpperCamelCase   							=common_inputs['attention_mask']
         if self.use_past:
              __UpperCamelCase   							=ordered_inputs['attention_mask'].dtype
              __UpperCamelCase   							=torch.cat(
                  [ordered_inputs['attention_mask'], torch.ones(A_ ,       A_ ,       dtype=A_   )] ,       dim=1   )

         return ordered_inputs






    @property
    def _a (      self   )  ->	int:
         return 13









import pprint

import requests

_A			=						'https://zenquotes.io/api'

def 						_UpperCAmelCase    (      ):
     return requests.get(API_ENDPOINT_URL + '/today'    ).json()

def 						_UpperCAmelCase    (      ):
     return requests.get(API_ENDPOINT_URL + '/random'    ).json()


if __name__ == "__main__":
   _A			=						random_quotes()
   pprint.pprint(response)





