'''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       _a    (		__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      :       Optional[Any]   ,				lowercase_      :       Tuple=50_400   ,				lowercase_      :       int=2_048   ,				lowercase_      :       Optional[Any]=4_096   ,				lowercase_      :       int=28   ,				lowercase_      :       int=16   ,				lowercase_      :       str=64   ,				lowercase_      :       Optional[Any]=None   ,				lowercase_      :       Tuple="gelu_new"   ,				lowercase_      :       str=0.0   ,				lowercase_      :       Dict=0.0   ,				lowercase_      :       Tuple=0.0   ,				lowercase_      :       Any=1e-5   ,				lowercase_      :       Any=0.0_2   ,				lowercase_      :       Union[str, Any]=True   ,				lowercase_      :       Any=50_256   ,				lowercase_      :       Union[str, Any]=50_256   ,				lowercase_      :       List[Any]=False   ,				**lowercase_      :       Optional[Any]   ,				):







    '''simple docstring'''


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

    lowercase_     =       bos_token_id
    lowercase_     =       eos_token_id

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






class       _a    (		__a      ):


  """simple docstring"""

  def __init__(		self      :       List[Any]   ,				lowercase_      :       PretrainedConfig   ,				lowercase_      :       str = "default"   ,				lowercase_      :       List[PatchingSpec] = None   ,				lowercase_      :       bool = False   ,				):







    '''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?
      lowercase_     =       0




  @property
  def 		lowerCamelCase__  (		self      :       int      ):







    '''simple docstring'''


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

    return common_inputs




  @property
  def 		lowerCamelCase__  (		self      :       Dict      ):







    '''simple docstring'''


    return self._config.n_layer




  @property
  def 		lowerCamelCase__  (		self      :       List[str]      ):







    '''simple docstring'''


    return self._config.n_head




  def 		lowerCamelCase__  (		self      :       int   ,				lowercase_      :       PreTrainedTokenizer   ,				lowercase_      :       int = -1   ,				lowercase_      :       int = -1   ,				lowercase_      :       bool = False   ,				lowercase_      :       Optional[TensorType] = None   ,				):







    '''simple docstring'''


    lowercase_     =       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()
    lowercase_     =       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

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

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

    return ordered_inputs





  @property
  def 		lowerCamelCase__  (		self      :       Optional[Any]      ):







    '''simple docstring'''


    return 13


'''simple docstring'''


from typing import TYPE_CHECKING

from ...file_utils import _LazyModule, is_torch_available
from ...utils import OptionalDependencyNotAvailable


__snake_case						  =		{
    """configuration_gpt_neox_japanese""": ["""GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoXJapaneseConfig"""],
    """tokenization_gpt_neox_japanese""": ["""GPTNeoXJapaneseTokenizer"""],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __snake_case						  =		[
           """GPT_NEOX_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST""",
           """GPTNeoXJapaneseForCausalLM""",
           """GPTNeoXJapaneseLayer""",
           """GPTNeoXJapaneseModel""",
           """GPTNeoXJapanesePreTrainedModel""",
       ]


if TYPE_CHECKING:
       from .configuration_gpt_neox_japanese import GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTNeoXJapaneseConfig
       from .tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_gpt_neox_japanese import (
                  GPT_NEOX_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST,
                  GPTNeoXJapaneseForCausalLM,
                  GPTNeoXJapaneseLayer,
                  GPTNeoXJapaneseModel,
                  GPTNeoXJapanesePreTrainedModel,
              )


else:
       import sys

       __snake_case						  =		_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)

