





"""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__						= logging.get_logger(__name__)


lowerCamelCase__						= {
    "Salesforce/codegen-350M-nl": "https://huggingface.co/Salesforce/codegen-350M-nl/resolve/main/config.json",
    "Salesforce/codegen-350M-multi": "https://huggingface.co/Salesforce/codegen-350M-multi/resolve/main/config.json",
    "Salesforce/codegen-350M-mono": "https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/config.json",
    "Salesforce/codegen-2B-nl": "https://huggingface.co/Salesforce/codegen-2B-nl/resolve/main/config.json",
    "Salesforce/codegen-2B-multi": "https://huggingface.co/Salesforce/codegen-2B-multi/resolve/main/config.json",
    "Salesforce/codegen-2B-mono": "https://huggingface.co/Salesforce/codegen-2B-mono/resolve/main/config.json",
    "Salesforce/codegen-6B-nl": "https://huggingface.co/Salesforce/codegen-6B-nl/resolve/main/config.json",
    "Salesforce/codegen-6B-multi": "https://huggingface.co/Salesforce/codegen-6B-multi/resolve/main/config.json",
    "Salesforce/codegen-6B-mono": "https://huggingface.co/Salesforce/codegen-6B-mono/resolve/main/config.json",
    "Salesforce/codegen-16B-nl": "https://huggingface.co/Salesforce/codegen-16B-nl/resolve/main/config.json",
    "Salesforce/codegen-16B-multi": "https://huggingface.co/Salesforce/codegen-16B-multi/resolve/main/config.json",
    "Salesforce/codegen-16B-mono": "https://huggingface.co/Salesforce/codegen-16B-mono/resolve/main/config.json",
}



class   __SCREAMING_SNAKE_CASE     (    _UpperCamelCase ):







  '''simple docstring'''


  SCREAMING_SNAKE_CASE__				:Dict						  =       "codegen"
  SCREAMING_SNAKE_CASE__				:int						  =       {
      "max_position_embeddings": "n_positions",
      "hidden_size": "n_embd",
      "num_attention_heads": "n_head",
      "num_hidden_layers": "n_layer",
  }

  def __init__(		self :							Tuple       , __a :							List[Any]=5_0400       , __a :							Union[str, Any]=2048       , __a :							Optional[int]=2048       , __a :							Union[str, Any]=4096       , __a :							List[str]=28       , __a :							Union[str, Any]=16       , __a :							Dict=64       , __a :							List[str]=None       , __a :							List[Any]="gelu_new"       , __a :							Optional[int]=0.0       , __a :							Any=0.0       , __a :							Optional[Any]=0.0       , __a :							Optional[int]=1e-5       , __a :							str=0.02       , __a :							Union[str, Any]=True       , __a :							List[Any]=5_0256       , __a :							Tuple=5_0256       , __a :							Tuple=False       , **__a :							Union[str, Any]       , )		->					str:
        _UpperCamelCase   :						List[Any]    =							vocab_size
        _UpperCamelCase   :						str    =							n_ctx
        _UpperCamelCase   :						Optional[Any]    =							n_positions
        _UpperCamelCase   :						List[str]    =							n_embd
        _UpperCamelCase   :						Union[str, Any]    =							n_layer
        _UpperCamelCase   :						int    =							n_head
        _UpperCamelCase   :						int    =							n_inner
        _UpperCamelCase   :						Union[str, Any]    =							rotary_dim
        _UpperCamelCase   :						Dict    =							activation_function
        _UpperCamelCase   :						List[Any]    =							resid_pdrop
        _UpperCamelCase   :						Tuple    =							embd_pdrop
        _UpperCamelCase   :						Optional[int]    =							attn_pdrop
        _UpperCamelCase   :						Tuple    =							layer_norm_epsilon
        _UpperCamelCase   :						Optional[Any]    =							initializer_range
        _UpperCamelCase   :						str    =							use_cache

        _UpperCamelCase   :						Any    =							bos_token_id
        _UpperCamelCase   :						Optional[Any]    =							eos_token_id

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





class   __SCREAMING_SNAKE_CASE     (    _UpperCamelCase ):







  '''simple docstring'''


  def __init__(		self :							List[Any]       , __a :							PretrainedConfig       , __a :							str = "default"       , __a :							List[PatchingSpec] = None       , __a :							bool = False       , )		->					Tuple:
        super().__init__(__a       , task=__a       , patching_specs=__a       , use_past=__a						)
        if not getattr(self._config       , "pad_token_id"       , __a						):
              # TODO: how to do that better?
              _UpperCamelCase   :						Union[str, Any]    =							0

  @property
  def  __SCREAMING_SNAKE_CASE					(		self :							Tuple						)		->					Mapping[str, Mapping[int, str]]:
        _UpperCamelCase   :						Optional[Any]    =							OrderedDict({"input_ids": {0: "batch", 1: "sequence"}}						)
        if self.use_past:
              self.fill_with_past_key_values_(__a       , direction="inputs"						)
              _UpperCamelCase   :						Tuple    =							{0: "batch", 1: "past_sequence + sequence"}
        else:
              _UpperCamelCase   :						Tuple    =							{0: "batch", 1: "sequence"}

        return common_inputs

  @property
  def  __SCREAMING_SNAKE_CASE					(		self :							Any						)		->					int:
        return self._config.n_layer

  @property
  def  __SCREAMING_SNAKE_CASE					(		self :							Optional[int]						)		->					int:
        return self._config.n_head

  def  __SCREAMING_SNAKE_CASE					(		self :							int       , __a :							PreTrainedTokenizer       , __a :							int = -1       , __a :							int = -1       , __a :							bool = False       , __a :							Optional[TensorType] = None       , )		->					Mapping[str, Any]:
        _UpperCamelCase   :						List[Any]    =							super(__a       , self						).generate_dummy_inputs(
            __a       , batch_size=__a       , seq_length=__a       , is_pair=__a       , framework=__a						)

        # We need to order the input in the way they appears in the forward()
        _UpperCamelCase   :						Optional[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

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

        _UpperCamelCase   :						Union[str, Any]    =							common_inputs["attention_mask"]
        if self.use_past:
              _UpperCamelCase   :						Tuple    =							ordered_inputs["attention_mask"].dtype
              _UpperCamelCase   :						List[Any]    =							torch.cat(
                  [ordered_inputs["attention_mask"], torch.ones(__a       , __a       , dtype=__a						)]       , dim=1						)

        return ordered_inputs


  @property
  def  __SCREAMING_SNAKE_CASE					(		self :							Optional[int]						)		->					int:
        return 13







"""simple docstring"""


from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowerCamelCase__						= logging.get_logger(__name__)

lowerCamelCase__						= {
    "google/mobilenet_v1_1.0_224": "https://huggingface.co/google/mobilenet_v1_1.0_224/resolve/main/config.json",
    "google/mobilenet_v1_0.75_192": "https://huggingface.co/google/mobilenet_v1_0.75_192/resolve/main/config.json",
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
}



class   __SCREAMING_SNAKE_CASE     (    _UpperCamelCase ):







  '''simple docstring'''


  SCREAMING_SNAKE_CASE__				:int						  =       "mobilenet_v1"

  def __init__(		self :							Optional[int]       , __a :							List[str]=3       , __a :							Union[str, Any]=224       , __a :							Tuple=1.0       , __a :							List[Any]=8       , __a :							Union[str, Any]="relu6"       , __a :							Dict=True       , __a :							Tuple=0.9_99       , __a :							Dict=0.02       , __a :							Any=0.0_01       , **__a :							Any       , )		->					int:
        super().__init__(**__a						)

        if depth_multiplier <= 0:
              raise ValueError("depth_multiplier must be greater than zero."						)

        _UpperCamelCase   :						Any    =							num_channels
        _UpperCamelCase   :						Optional[Any]    =							image_size
        _UpperCamelCase   :						Optional[Any]    =							depth_multiplier
        _UpperCamelCase   :						int    =							min_depth
        _UpperCamelCase   :						List[str]    =							hidden_act
        _UpperCamelCase   :						Union[str, Any]    =							tf_padding
        _UpperCamelCase   :						int    =							classifier_dropout_prob
        _UpperCamelCase   :						Optional[int]    =							initializer_range
        _UpperCamelCase   :						Union[str, Any]    =							layer_norm_eps





class   __SCREAMING_SNAKE_CASE     (    _UpperCamelCase ):







  '''simple docstring'''


  SCREAMING_SNAKE_CASE__				:List[Any]						  =       version.parse("1.11" )

  @property
  def  __SCREAMING_SNAKE_CASE					(		self :							List[str]						)		->					Mapping[str, Mapping[int, str]]:
        return OrderedDict([("pixel_values", {0: "batch"})]						)

  @property
  def  __SCREAMING_SNAKE_CASE					(		self :							Optional[int]						)		->					Mapping[str, Mapping[int, str]]:
        if self.task == "image-classification":
              return OrderedDict([("logits", {0: "batch"})]						)
        else:
              return OrderedDict([("last_hidden_state", {0: "batch"}), ("pooler_output", {0: "batch"})]						)


  @property
  def  __SCREAMING_SNAKE_CASE					(		self :							Tuple						)		->					float:
        return 1e-4
