


'''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							:   List[str]  						=	logging.get_logger(__name__)


lowerCamelCase							:   List[str]  						=	{
    '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   __lowerCAmelCase						(lowercase_     ):





      '''simple docstring'''






      lowerCAmelCase__					:     Any  					=							"""codegen"""
      lowerCAmelCase__					:     Union[str, Any]  					=							{
          """max_position_embeddings""": """n_positions""",
          """hidden_size""": """n_embd""",
          """num_attention_heads""": """n_head""",
          """num_hidden_layers""": """n_layer""",
      }



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

             '''simple docstring'''







             lowercase__      			= vocab_size
             lowercase__      			= n_ctx
             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=UpperCamelCase   ,						eos_token_id=UpperCamelCase   ,						tie_word_embeddings=UpperCamelCase   ,						**UpperCamelCase )






class   __lowerCAmelCase						(lowercase_     ):





      '''simple docstring'''






      def __init__(self    :    Union[str, Any]   ,						UpperCamelCase    :    PretrainedConfig   ,						UpperCamelCase    :    str = "default"   ,						UpperCamelCase    :    List[PatchingSpec] = None   ,						UpperCamelCase    :    bool = 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?
                    lowercase__      			= 0



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

             '''simple docstring'''







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

             return common_inputs



      @property
      def       UpperCamelCase__		(self    :    Any ):

             '''simple docstring'''







             return self._config.n_layer



      @property
      def       UpperCamelCase__		(self    :    List[Any] ):

             '''simple docstring'''







             return self._config.n_head



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

             '''simple docstring'''







             lowercase__      			= 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()
             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(UpperCamelCase ), torch.zeros(UpperCamelCase )) 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(UpperCamelCase   ,						UpperCamelCase   ,						dtype=UpperCamelCase )]   ,						dim=1 )

             return ordered_inputs






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

             '''simple docstring'''







             return 13








'''simple docstring'''

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase							:   Tuple  						=	logging.get_logger(__name__)

lowerCamelCase							:   Dict  						=	{
    'microsoft/cvt-13': 'https://huggingface.co/microsoft/cvt-13/resolve/main/config.json',
    # See all Cvt models at https://huggingface.co/models?filter=cvt
}
class   __lowerCAmelCase						(lowercase_     ):





      '''simple docstring'''






      lowerCAmelCase__					:     Tuple  					=							"""cvt"""



      def __init__(self    :    int   ,						UpperCamelCase    :    List[Any]=3   ,						UpperCamelCase    :    int=[7, 3, 3]   ,						UpperCamelCase    :    str=[4, 2, 2]   ,						UpperCamelCase    :    Dict=[2, 1, 1]   ,						UpperCamelCase    :    Dict=[64, 192, 384]   ,						UpperCamelCase    :    Dict=[1, 3, 6]   ,						UpperCamelCase    :    Dict=[1, 2, 10]   ,						UpperCamelCase    :    Any=[4.0, 4.0, 4.0]   ,						UpperCamelCase    :    Optional[int]=[0.0, 0.0, 0.0]   ,						UpperCamelCase    :    Optional[int]=[0.0, 0.0, 0.0]   ,						UpperCamelCase    :    int=[0.0, 0.0, 0.1]   ,						UpperCamelCase    :    Any=[True, True, True]   ,						UpperCamelCase    :    int=[False, False, True]   ,						UpperCamelCase    :    Union[str, Any]=["dw_bn", "dw_bn", "dw_bn"]   ,						UpperCamelCase    :    Optional[int]=[3, 3, 3]   ,						UpperCamelCase    :    Tuple=[1, 1, 1]   ,						UpperCamelCase    :    Any=[2, 2, 2]   ,						UpperCamelCase    :    Dict=[1, 1, 1]   ,						UpperCamelCase    :    List[str]=[1, 1, 1]   ,						UpperCamelCase    :    str=0.02   ,						UpperCamelCase    :    int=1E-12   ,						**UpperCamelCase    :    Union[str, Any]   ,						):

             '''simple docstring'''







             super().__init__(**UpperCamelCase )
             lowercase__      			= num_channels
             lowercase__      			= patch_sizes
             lowercase__      			= patch_stride
             lowercase__      			= patch_padding
             lowercase__      			= embed_dim
             lowercase__      			= num_heads
             lowercase__      			= depth
             lowercase__      			= mlp_ratio
             lowercase__      			= attention_drop_rate
             lowercase__      			= drop_rate
             lowercase__      			= drop_path_rate
             lowercase__      			= qkv_bias
             lowercase__      			= cls_token
             lowercase__      			= qkv_projection_method
             lowercase__      			= kernel_qkv
             lowercase__      			= padding_kv
             lowercase__      			= stride_kv
             lowercase__      			= padding_q
             lowercase__      			= stride_q
             lowercase__      			= initializer_range
             lowercase__      			= layer_norm_eps




