




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


lowerCamelCase__			:       List[str]         =							logging.get_logger(__name__)

lowerCamelCase__			:       Dict         =							{
    '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 	lowerCamelCase_							(				_SCREAMING_SNAKE_CASE ):


 '''simple docstring'''







 lowercase_       =   "bloom"
 lowercase_       =   ["past_key_values"]
 lowercase_       =   {
     "num_hidden_layers": "n_layer",
     "num_attention_heads": "n_head",
 }



 def __init__(							self  :		Union[str, Any]    ,    _lowerCAmelCase  :		Optional[int]=250_880    ,    _lowerCAmelCase  :		Dict=64    ,    _lowerCAmelCase  :		Optional[Any]=2    ,    _lowerCAmelCase  :		int=8    ,    _lowerCAmelCase  :		str=1E-5    ,    _lowerCAmelCase  :		Any=0.02    ,    _lowerCAmelCase  :		str=True    ,    _lowerCAmelCase  :		List[Any]=1    ,    _lowerCAmelCase  :		Dict=2    ,    _lowerCAmelCase  :		List[Any]=False    ,    _lowerCAmelCase  :		Dict=0.0    ,    _lowerCAmelCase  :		Union[str, Any]=0.0    ,    _lowerCAmelCase  :		List[str]=1    ,    _lowerCAmelCase  :		Any=False    ,    **_lowerCAmelCase  :		List[str]    ,    ):
       SCREAMING_SNAKE_CASE_     						=      vocab_size
       # Backward compatibility with n_embed kwarg
       SCREAMING_SNAKE_CASE_     						=      kwargs.pop('n_embed'    ,    _lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_     						=      hidden_size if n_embed is None else n_embed
       SCREAMING_SNAKE_CASE_     						=      n_layer
       SCREAMING_SNAKE_CASE_     						=      n_head
       SCREAMING_SNAKE_CASE_     						=      layer_norm_epsilon
       SCREAMING_SNAKE_CASE_     						=      initializer_range
       SCREAMING_SNAKE_CASE_     						=      use_cache
       SCREAMING_SNAKE_CASE_     						=      pretraining_tp
       SCREAMING_SNAKE_CASE_     						=      apply_residual_connection_post_layernorm
       SCREAMING_SNAKE_CASE_     						=      hidden_dropout
       SCREAMING_SNAKE_CASE_     						=      attention_dropout

       SCREAMING_SNAKE_CASE_     						=      bos_token_id
       SCREAMING_SNAKE_CASE_     						=      eos_token_id
       SCREAMING_SNAKE_CASE_     						=      slow_but_exact

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





class 	lowerCamelCase_							(				_SCREAMING_SNAKE_CASE ):


 '''simple docstring'''







 lowercase_       =   version.parse("1.12" )



 def __init__(							self  :		str    ,    _lowerCAmelCase  :		PretrainedConfig    ,    _lowerCAmelCase  :		str = "default"    ,    _lowerCAmelCase  :		List[PatchingSpec] = None    ,    _lowerCAmelCase  :		bool = False    ,    ):
       super().__init__(_lowerCAmelCase    ,    task=_lowerCAmelCase    ,    patching_specs=_lowerCAmelCase    ,    use_past=_lowerCAmelCase						)
       if not getattr(self._config    ,    'pad_token_id'    ,    _lowerCAmelCase						):
             # TODO: how to do that better?
             SCREAMING_SNAKE_CASE_     						=      0



 @property
 def 				lowerCAmelCase_  (							self  :		Optional[Any]						):
       SCREAMING_SNAKE_CASE_     						=      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_(_lowerCAmelCase    ,    direction='inputs'    ,    inverted_values_shape=_lowerCAmelCase						)
             SCREAMING_SNAKE_CASE_     						=      {0: 'batch', 1: 'past_sequence + sequence'}
       else:
             SCREAMING_SNAKE_CASE_     						=      {0: 'batch', 1: 'sequence'}

       return common_inputs



 @property
 def 				lowerCAmelCase_  (							self  :		Optional[int]						):
       return self._config.n_layer



 @property
 def 				lowerCAmelCase_  (							self  :		Union[str, Any]						):
       return self._config.n_head



 @property
 def 				lowerCAmelCase_  (							self  :		Tuple						):
       return 1E-3



 def 				lowerCAmelCase_  (							self  :		List[str]    ,    _lowerCAmelCase  :		"PreTrainedTokenizer"    ,    _lowerCAmelCase  :		int = -1    ,    _lowerCAmelCase  :		int = -1    ,    _lowerCAmelCase  :		bool = False    ,    _lowerCAmelCase  :		Optional["TensorType"] = None    ,    ):
       SCREAMING_SNAKE_CASE_     						=      super(_lowerCAmelCase    ,    self						).generate_dummy_inputs(
           _lowerCAmelCase    ,    batch_size=_lowerCAmelCase    ,    seq_length=_lowerCAmelCase    ,    is_pair=_lowerCAmelCase    ,    framework=_lowerCAmelCase						)

       # We need to order the input in the way they appears in the forward()
       SCREAMING_SNAKE_CASE_     						=      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

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

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

       return ordered_inputs




 @property
 def 				lowerCAmelCase_  (							self  :		List[Any]						):
       return 13





def  UpperCAmelCase_							(				__UpperCAmelCase						:     int      ,      __UpperCAmelCase						:     int							) ->			int:
      return int((input_a, input_a).count(0							) != 0							)

def  UpperCAmelCase_							(				) ->			None:
      assert nand_gate(0      ,      0							) == 1
      assert nand_gate(0      ,      1							) == 1
      assert nand_gate(1      ,      0							) == 1
      assert nand_gate(1      ,      1							) == 0


if __name__ == "__main__":
   print(nand_gate(0, 0))
   print(nand_gate(0, 1))
   print(nand_gate(1, 0))
   print(nand_gate(1, 1))