


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


__snake_case				 =	logging.get_logger(__name__)

__snake_case				 =	{
    '''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   lowercase      (				A__   ):

		"""simple docstring"""

		_a       					=							'gptj'
		_a       					=							{
		    'max_position_embeddings': 'n_positions',
		    'hidden_size': 'n_embd',
		    'num_attention_heads': 'n_head',
		    'num_hidden_layers': 'n_layer',
		}




		def __init__(						self       ,  UpperCamelCase_=50400       ,  UpperCamelCase_=2048       ,  UpperCamelCase_=4096       ,  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_=50256       ,  UpperCamelCase_=50256       ,  UpperCamelCase_=False       ,  **UpperCamelCase_       ,  ):

							'''simple docstring'''


							UpperCamelCase__  :Union[str, Any]				   =					vocab_size
							UpperCamelCase__  :List[Any]				   =					n_positions
							UpperCamelCase__  :Optional[Any]				   =					n_embd
							UpperCamelCase__  :Any				   =					n_layer
							UpperCamelCase__  :List[str]				   =					n_head
							UpperCamelCase__  :Optional[Any]				   =					n_inner
							UpperCamelCase__  :Union[str, Any]				   =					rotary_dim
							UpperCamelCase__  :Any				   =					activation_function
							UpperCamelCase__  :Dict				   =					resid_pdrop
							UpperCamelCase__  :int				   =					embd_pdrop
							UpperCamelCase__  :Optional[Any]				   =					attn_pdrop
							UpperCamelCase__  :List[str]				   =					layer_norm_epsilon
							UpperCamelCase__  :Optional[int]				   =					initializer_range
							UpperCamelCase__  :str				   =					use_cache

							UpperCamelCase__  :str				   =					bos_token_id
							UpperCamelCase__  :List[str]				   =					eos_token_id

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



class   lowercase      (				A__   ):

		"""simple docstring"""

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

							'''simple docstring'''


							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?
												UpperCamelCase__  :Dict				   =					0




		@property
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							UpperCamelCase__  :Tuple				   =					OrderedDict({'''input_ids''': {0: '''batch''', 1: '''sequence'''}}				)
							if self.use_past:
												self.fill_with_past_key_values_(UpperCamelCase_       ,  direction='''inputs'''				)
												UpperCamelCase__  :str				   =					{0: '''batch''', 1: '''past_sequence + sequence'''}
							else:
												UpperCamelCase__  :Union[str, Any]				   =					{0: '''batch''', 1: '''sequence'''}

							return common_inputs




		@property
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							return self._config.n_layer




		@property
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							return self._config.n_head




		def        lowerCAmelCase__							(						self       ,  UpperCamelCase_       ,  UpperCamelCase_ = -1       ,  UpperCamelCase_ = -1       ,  UpperCamelCase_ = False       ,  UpperCamelCase_ = None       ,  ):

							'''simple docstring'''


							UpperCamelCase__  :Optional[Any]				   =					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()
							UpperCamelCase__  :Dict				   =					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__   ,							UpperCamelCase__  :Dict				   =					common_inputs['''input_ids'''].shape
																	# Not using the same length for past_key_values
																	UpperCamelCase__  :Tuple				   =					seqlen + 2
																	UpperCamelCase__  :Union[str, Any]				   =					(
																	    batch,
																	    self.num_attention_heads,
																	    past_key_values_length,
																	    self._config.hidden_size // self.num_attention_heads,
																	)
																	UpperCamelCase__  :Tuple				   =					[
																	    (torch.zeros(UpperCamelCase_				), torch.zeros(UpperCamelCase_				)) for _ in range(self.num_layers				)
																	]

							UpperCamelCase__  :Optional[int]				   =					common_inputs['''attention_mask''']
							if self.use_past:
												UpperCamelCase__  :Any				   =					ordered_inputs['''attention_mask'''].dtype
												UpperCamelCase__  :Tuple				   =					torch.cat(
												    [ordered_inputs['''attention_mask'''], torch.ones(UpperCamelCase_       ,  UpperCamelCase_       ,  dtype=UpperCamelCase_				)]       ,  dim=1				)

							return ordered_inputs




		@property
		def        lowerCAmelCase__							(						self				):

							'''simple docstring'''


							return 13



'''simple docstring'''
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels
from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features
from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificationProcessor
from .xnli import xnli_output_modes, xnli_processors, xnli_tasks_num_labels