


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


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

_lowercase      :      List[Any]            =					{
    """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__(       __lowerCamelCase	):
    __magic_name__    :				Dict  		=	"""gptj"""
    __magic_name__    :				Optional[Any]  		=	{
        """max_position_embeddings""": """n_positions""",
        """hidden_size""": """n_embd""",
        """num_attention_heads""": """n_head""",
        """num_hidden_layers""": """n_layer""",
    }




    def __init__(		self      :			str				,   lowerCAmelCase      :			Tuple=50400				,   lowerCAmelCase      :			Tuple=2048				,   lowerCAmelCase      :			Any=4096				,   lowerCAmelCase      :			Dict=28				,   lowerCAmelCase      :			Tuple=16				,   lowerCAmelCase      :			Optional[int]=64				,   lowerCAmelCase      :			str=None				,   lowerCAmelCase      :			List[Any]="gelu_new"				,   lowerCAmelCase      :			int=0.0				,   lowerCAmelCase      :			Dict=0.0				,   lowerCAmelCase      :			List[str]=0.0				,   lowerCAmelCase      :			Tuple=1E-5				,   lowerCAmelCase      :			List[str]=0.02				,   lowerCAmelCase      :			Any=True				,   lowerCAmelCase      :			List[Any]=50256				,   lowerCAmelCase      :			Union[str, Any]=50256				,   lowerCAmelCase      :			Dict=False				,   **lowerCAmelCase      :			Union[str, Any]				,   )->					Dict:

          """simple docstring"""




          UpperCAmelCase					    =     vocab_size
          UpperCAmelCase					    =     n_positions
          UpperCAmelCase					    =     n_embd
          UpperCAmelCase					    =     n_layer
          UpperCAmelCase					    =     n_head
          UpperCAmelCase					    =     n_inner
          UpperCAmelCase					    =     rotary_dim
          UpperCAmelCase					    =     activation_function
          UpperCAmelCase					    =     resid_pdrop
          UpperCAmelCase					    =     embd_pdrop
          UpperCAmelCase					    =     attn_pdrop
          UpperCAmelCase					    =     layer_norm_epsilon
          UpperCAmelCase					    =     initializer_range
          UpperCAmelCase					    =     use_cache

          UpperCAmelCase					    =     bos_token_id
          UpperCAmelCase					    =     eos_token_id

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







class 	UpperCamelCase__(       __lowerCamelCase	):




    def __init__(		self      :			List[str]				,   lowerCAmelCase      :			PretrainedConfig				,   lowerCAmelCase      :			str = "default"				,   lowerCAmelCase      :			List[PatchingSpec] = None				,   lowerCAmelCase      :			bool = False				,   )->					Optional[int]:

          """simple docstring"""




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




    @property
    def 					a__(		self      :			Optional[int]				)->					List[str]:

          """simple docstring"""




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

          return common_inputs




    @property
    def 					a__(		self      :			Dict				)->					str:

          """simple docstring"""




          return self._config.n_layer




    @property
    def 					a__(		self      :			Optional[Any]				)->					Any:

          """simple docstring"""




          return self._config.n_head




    def 					a__(		self      :			Optional[Any]				,   lowerCAmelCase      :			PreTrainedTokenizer				,   lowerCAmelCase      :			int = -1				,   lowerCAmelCase      :			int = -1				,   lowerCAmelCase      :			bool = False				,   lowerCAmelCase      :			Optional[TensorType] = None				,   )->					List[Any]:

          """simple docstring"""




          UpperCAmelCase					    =     super(__lowercase				,   self				).generate_dummy_inputs(
              __lowercase				,   batch_size=__lowercase				,   seq_length=__lowercase				,   is_pair=__lowercase				,   framework=__lowercase				)

          # 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					    =     common_inputs['''input_ids'''].shape
                      # Not using the same length for past_key_values
                      UpperCAmelCase					    =     seqlen + 2
                      UpperCAmelCase					    =     (
                          batch,
                          self.num_attention_heads,
                          past_key_values_length,
                          self._config.hidden_size // self.num_attention_heads,
                      )
                      UpperCAmelCase					    =     [
                          (torch.zeros(__lowercase				), torch.zeros(__lowercase				)) 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(__lowercase				,   __lowercase				,   dtype=__lowercase				)]				,   dim=1				)

          return ordered_inputs





    @property
    def 					a__(		self      :			Dict				)->					Optional[Any]:

          """simple docstring"""




          return 13









'''simple docstring'''



from .data_collator import (
    DataCollatorForLanguageModeling,
    DataCollatorForPermutationLanguageModeling,
    DataCollatorForSeqaSeq,
    DataCollatorForSOP,
    DataCollatorForTokenClassification,
    DataCollatorForWholeWordMask,
    DataCollatorWithPadding,
    DefaultDataCollator,
    default_data_collator,
)
from .metrics import glue_compute_metrics, xnli_compute_metrics
from .processors import (
    DataProcessor,
    InputExample,
    InputFeatures,
    SingleSentenceClassificationProcessor,
    SquadExample,
    SquadFeatures,
    SquadVaProcessor,
    SquadVaProcessor,
    glue_convert_examples_to_features,
    glue_output_modes,
    glue_processors,
    glue_tasks_num_labels,
    squad_convert_examples_to_features,
    xnli_output_modes,
    xnli_processors,
    xnli_tasks_num_labels,
)





