




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

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


UpperCAmelCase    =					logging.get_logger(__name__)

UpperCAmelCase    =					{
    'EleutherAI/gpt-j-6B': 'https://huggingface.co/EleutherAI/gpt-j-6B/resolve/main/config.json',
    # See all GPT-J models at https://huggingface.co/models?filter=gpt_j
}







class lowerCAmelCase_		(				UpperCamelCase_ ):

 '''simple docstring'''

 __snake_case				=						"gptj"
 __snake_case				=						{
     "max_position_embeddings": "n_positions",
     "hidden_size": "n_embd",
     "num_attention_heads": "n_head",
     "num_hidden_layers": "n_layer",
 }



 def __init__(			self	,   _UpperCAmelCase=5_04_00	,   _UpperCAmelCase=20_48	,   _UpperCAmelCase=40_96	,   _UpperCAmelCase=28	,   _UpperCAmelCase=16	,   _UpperCAmelCase=64	,   _UpperCAmelCase=None	,   _UpperCAmelCase="gelu_new"	,   _UpperCAmelCase=0.0	,   _UpperCAmelCase=0.0	,   _UpperCAmelCase=0.0	,   _UpperCAmelCase=1E-5	,   _UpperCAmelCase=0.02	,   _UpperCAmelCase=True	,   _UpperCAmelCase=5_02_56	,   _UpperCAmelCase=5_02_56	,   _UpperCAmelCase=False	,   **_UpperCAmelCase	,   ):
       snake_case_ =   vocab_size
       snake_case_ =   n_positions
       snake_case_ =   n_embd
       snake_case_ =   n_layer
       snake_case_ =   n_head
       snake_case_ =   n_inner
       snake_case_ =   rotary_dim
       snake_case_ =   activation_function
       snake_case_ =   resid_pdrop
       snake_case_ =   embd_pdrop
       snake_case_ =   attn_pdrop
       snake_case_ =   layer_norm_epsilon
       snake_case_ =   initializer_range
       snake_case_ =   use_cache

       snake_case_ =   bos_token_id
       snake_case_ =   eos_token_id

       super().__init__(
           bos_token_id=_UpperCAmelCase	,   eos_token_id=_UpperCAmelCase	,   tie_word_embeddings=_UpperCAmelCase	,   **_UpperCAmelCase      )







class lowerCAmelCase_		(				UpperCamelCase_ ):

 '''simple docstring'''

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



 @property
 def 		UpperCamelCase__  (			self      ):
       snake_case_ =   OrderedDict({'''input_ids''': {0: '''batch''', 1: '''sequence'''}}      )
       if self.use_past:
             self.fill_with_past_key_values_(_UpperCAmelCase	,   direction='''inputs'''      )
             snake_case_ =   {0: '''batch''', 1: '''past_sequence + sequence'''}
       else:
             snake_case_ =   {0: '''batch''', 1: '''sequence'''}

       return common_inputs



 @property
 def 		UpperCamelCase__  (			self      ):
       return self._config.n_layer



 @property
 def 		UpperCamelCase__  (			self      ):
       return self._config.n_head



 def 		UpperCamelCase__  (			self	,   _UpperCAmelCase	,   _UpperCAmelCase = -1	,   _UpperCAmelCase = -1	,   _UpperCAmelCase = False	,   _UpperCAmelCase = None	,   ):
       snake_case_ =   super(_UpperCAmelCase	,   self      ).generate_dummy_inputs(
           _UpperCAmelCase	,   batch_size=_UpperCAmelCase	,   seq_length=_UpperCAmelCase	,   is_pair=_UpperCAmelCase	,   framework=_UpperCAmelCase      )

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

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

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

       return ordered_inputs





 @property
 def 		UpperCamelCase__  (			self      ):
       return 13



def  __lowerCAmelCase					(SCREAMING_SNAKE_CASE      ,      SCREAMING_SNAKE_CASE      )->						int:




      """simple docstring"""

      return int((input_a, input_a).count(0      ) == 0      )






def  __lowerCAmelCase					()->						None:




      """simple docstring"""

      assert and_gate(0      ,      0      ) == 0
      assert and_gate(0      ,      1      ) == 0
      assert and_gate(1      ,      0      ) == 0
      assert and_gate(1      ,      1      ) == 1


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