


'''simple docstring'''







lowerCAmelCase    :     Tuple					=						[
    """Audio""",
    """Array2D""",
    """Array3D""",
    """Array4D""",
    """Array5D""",
    """ClassLabel""",
    """Features""",
    """Sequence""",
    """Value""",
    """Image""",
    """Translation""",
    """TranslationVariableLanguages""",
]
from .audio import Audio
from .features import ArrayaD, ArrayaD, ArrayaD, ArrayaD, ClassLabel, Features, Sequence, Value
from .image import Image
from .translation import Translation, TranslationVariableLanguages





'''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


lowerCAmelCase    :     Optional[Any]					=						logging.get_logger(__name__)

lowerCAmelCase    :     str					=						{
    """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 	UpperCamelCase__					( SCREAMING_SNAKE_CASE_	):



     """simple docstring"""






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







     def __init__( self      ,	snake_case__=5_0400      ,	snake_case__=2048      ,	snake_case__=4096      ,	snake_case__=28      ,	snake_case__=16      ,	snake_case__=64      ,	snake_case__=None      ,	snake_case__="gelu_new"      ,	snake_case__=0.0      ,	snake_case__=0.0      ,	snake_case__=0.0      ,	snake_case__=1E-5      ,	snake_case__=0.02      ,	snake_case__=True      ,	snake_case__=5_0256      ,	snake_case__=5_0256      ,	snake_case__=False      ,	**snake_case__      ,	):

            '''simple docstring'''

            _lowerCAmelCase    :							int   			=       vocab_size
            _lowerCAmelCase    :							Optional[int]   			=       n_positions
            _lowerCAmelCase    :							Optional[int]   			=       n_embd
            _lowerCAmelCase    :							Optional[int]   			=       n_layer
            _lowerCAmelCase    :							str   			=       n_head
            _lowerCAmelCase    :							Tuple   			=       n_inner
            _lowerCAmelCase    :							Tuple   			=       rotary_dim
            _lowerCAmelCase    :							Optional[int]   			=       activation_function
            _lowerCAmelCase    :							Any   			=       resid_pdrop
            _lowerCAmelCase    :							List[str]   			=       embd_pdrop
            _lowerCAmelCase    :							int   			=       attn_pdrop
            _lowerCAmelCase    :							Any   			=       layer_norm_epsilon
            _lowerCAmelCase    :							Optional[int]   			=       initializer_range
            _lowerCAmelCase    :							List[str]   			=       use_cache

            _lowerCAmelCase    :							Dict   			=       bos_token_id
            _lowerCAmelCase    :							Any   			=       eos_token_id

            super().__init__(
                bos_token_id=snake_case__      ,	eos_token_id=snake_case__      ,	tie_word_embeddings=snake_case__      ,	**snake_case__   )
class 	UpperCamelCase__					( SCREAMING_SNAKE_CASE_	):



     """simple docstring"""






     def __init__( self      ,	snake_case__      ,	snake_case__ = "default"      ,	snake_case__ = None      ,	snake_case__ = False      ,	):

            '''simple docstring'''

            super().__init__(snake_case__      ,	task=snake_case__      ,	patching_specs=snake_case__      ,	use_past=snake_case__   )
            if not getattr(self._config      ,	'pad_token_id'      ,	snake_case__   ):
                   # TODO: how to do that better?
                   _lowerCAmelCase    :							Any   			=       0







     @property
     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							str   			=       OrderedDict({'input_ids': {0: 'batch', 1: 'sequence'}}   )
            if self.use_past:
                   self.fill_with_past_key_values_(snake_case__      ,	direction='inputs'   )
                   _lowerCAmelCase    :							int   			=       {0: 'batch', 1: 'past_sequence + sequence'}
            else:
                   _lowerCAmelCase    :							int   			=       {0: 'batch', 1: 'sequence'}

            return common_inputs







     @property
     def a	( self   ):

            '''simple docstring'''

            return self._config.n_layer







     @property
     def a	( self   ):

            '''simple docstring'''

            return self._config.n_head







     def a	( self      ,	snake_case__      ,	snake_case__ = -1      ,	snake_case__ = -1      ,	snake_case__ = False      ,	snake_case__ = None      ,	):

            '''simple docstring'''

            _lowerCAmelCase    :							Optional[Any]   			=       super(snake_case__      ,	self   ).generate_dummy_inputs(
                snake_case__      ,	batch_size=snake_case__      ,	seq_length=snake_case__      ,	is_pair=snake_case__      ,	framework=snake_case__   )

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

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

            _lowerCAmelCase    :							Tuple   			=       common_inputs['attention_mask']
            if self.use_past:
                   _lowerCAmelCase    :							Any   			=       ordered_inputs['attention_mask'].dtype
                   _lowerCAmelCase    :							Union[str, Any]   			=       torch.cat(
                       [ordered_inputs['attention_mask'], torch.ones(snake_case__      ,	snake_case__      ,	dtype=snake_case__   )]      ,	dim=1   )

            return ordered_inputs







     @property
     def a	( self   ):

            '''simple docstring'''

            return 13

