


'''simple docstring'''




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


_a      :      Dict       				=      logging.get_logger(__name__)

_a      :      str       				=      {
    "gpt2": "https://huggingface.co/gpt2/resolve/main/config.json",
    "gpt2-medium": "https://huggingface.co/gpt2-medium/resolve/main/config.json",
    "gpt2-large": "https://huggingface.co/gpt2-large/resolve/main/config.json",
    "gpt2-xl": "https://huggingface.co/gpt2-xl/resolve/main/config.json",
    "distilgpt2": "https://huggingface.co/distilgpt2/resolve/main/config.json",
}




class  _lowercase   (  a__       ):
   _SCREAMING_SNAKE_CASE     :     Dict									=  "gpt2"
   _SCREAMING_SNAKE_CASE     :     Optional[int]									=  ["past_key_values"]
   _SCREAMING_SNAKE_CASE     :     Any									=  {
       "hidden_size": "n_embd",
       "max_position_embeddings": "n_positions",
       "num_attention_heads": "n_head",
       "num_hidden_layers": "n_layer",
   }
   def __init__(	self					:			Tuple					,      SCREAMING_SNAKE_CASE_					:			str=5_0257					,      SCREAMING_SNAKE_CASE_					:			Optional[int]=1024					,      SCREAMING_SNAKE_CASE_					:			int=768					,      SCREAMING_SNAKE_CASE_					:			int=12					,      SCREAMING_SNAKE_CASE_					:			Union[str, Any]=12					,      SCREAMING_SNAKE_CASE_					:			Dict=None					,      SCREAMING_SNAKE_CASE_					:			Optional[int]="gelu_new"					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]=0.1					,      SCREAMING_SNAKE_CASE_					:			str=0.1					,      SCREAMING_SNAKE_CASE_					:			Tuple=0.1					,      SCREAMING_SNAKE_CASE_					:			List[str]=1e-5					,      SCREAMING_SNAKE_CASE_					:			Optional[int]=0.0_2					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]="cls_index"					,      SCREAMING_SNAKE_CASE_					:			Any=True					,      SCREAMING_SNAKE_CASE_					:			Optional[int]=None					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]=True					,      SCREAMING_SNAKE_CASE_					:			Dict=0.1					,      SCREAMING_SNAKE_CASE_					:			Any=True					,      SCREAMING_SNAKE_CASE_					:			List[str]=True					,      SCREAMING_SNAKE_CASE_					:			Any=5_0256					,      SCREAMING_SNAKE_CASE_					:			Optional[Any]=5_0256					,      SCREAMING_SNAKE_CASE_					:			int=False					,      SCREAMING_SNAKE_CASE_					:			List[str]=False					,      **SCREAMING_SNAKE_CASE_					:			str					,      )   ->       List[Any]:
        __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    			=	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    			=	summary_type
        __snake_case    			=	summary_use_proj
        __snake_case    			=	summary_activation
        __snake_case    			=	summary_first_dropout
        __snake_case    			=	summary_proj_to_labels
        __snake_case    			=	scale_attn_weights
        __snake_case    			=	use_cache
        __snake_case    			=	scale_attn_by_inverse_layer_idx
        __snake_case    			=	reorder_and_upcast_attn

        __snake_case    			=	bos_token_id
        __snake_case    			=	eos_token_id

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




class  _lowercase   (  a__       ):
   def __init__(	self					:			Optional[int]					,      SCREAMING_SNAKE_CASE_					:			List[Any]					,      SCREAMING_SNAKE_CASE_					:			Tuple = "default"					,      SCREAMING_SNAKE_CASE_					:			Tuple = None					,      SCREAMING_SNAKE_CASE_					:			str = False					,      )   ->       Tuple:
        super().__init__(SCREAMING_SNAKE_CASE_					,      task=SCREAMING_SNAKE_CASE_					,      patching_specs=SCREAMING_SNAKE_CASE_					,      use_past=SCREAMING_SNAKE_CASE_			)
        if not getattr(self._config					,      'pad_token_id'					,      SCREAMING_SNAKE_CASE_			):
             # TODO: how to do that better?
             __snake_case    			=	0
   @property
   def a     (	self					:			List[Any]			)   ->       Mapping[str, Mapping[int, str]]:
        __snake_case    			=	OrderedDict({'input_ids': {0: 'batch', 1: 'sequence'}}			)
        if self.use_past:
             self.fill_with_past_key_values_(SCREAMING_SNAKE_CASE_					,      direction='inputs'			)
             __snake_case    			=	{0: 'batch', 1: 'past_sequence + sequence'}
        else:
             __snake_case    			=	{0: 'batch', 1: 'sequence'}

        return common_inputs
   @property
   def a     (	self					:			Any			)   ->       int:
        return self._config.n_layer
   @property
   def a     (	self					:			int			)   ->       int:
        return self._config.n_head
   def a     (	self					:			Optional[Any]					,      SCREAMING_SNAKE_CASE_					:			List[str]					,      SCREAMING_SNAKE_CASE_					:			List[Any] = -1					,      SCREAMING_SNAKE_CASE_					:			int = -1					,      SCREAMING_SNAKE_CASE_					:			Any = False					,      SCREAMING_SNAKE_CASE_					:			int = None					,      )   ->       Mapping[str, Any]:
        __snake_case    			=	super(SCREAMING_SNAKE_CASE_					,      self			).generate_dummy_inputs(
            SCREAMING_SNAKE_CASE_					,      batch_size=SCREAMING_SNAKE_CASE_					,      seq_length=SCREAMING_SNAKE_CASE_					,      is_pair=SCREAMING_SNAKE_CASE_					,      framework=SCREAMING_SNAKE_CASE_			)

        # 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(SCREAMING_SNAKE_CASE_			), torch.zeros(SCREAMING_SNAKE_CASE_			)) 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(SCREAMING_SNAKE_CASE_					,      SCREAMING_SNAKE_CASE_					,      dtype=SCREAMING_SNAKE_CASE_			)]					,      dim=1			)

        return ordered_inputs





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








'''simple docstring'''




def      _a		(lowercase__ :      int	) -> int:






     """simple docstring"""
     return 1 if input_a == 0 else 0





def      _a		() -> None:






     """simple docstring"""
     assert not_gate(0	) == 1
     assert not_gate(1	) == 0


if __name__ == "__main__":
       print(not_gate(0))
       print(not_gate(1))




