


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


__magic_name__						: int    =				logging.get_logger(__name__)

__magic_name__						: Optional[int]    =				{
    '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 			__snake_case   (lowerCamelCase  ):
							__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:    Dict     ,							A_:    Optional[int]=5_04_00     ,							A_:    List[Any]=20_48     ,							A_:    Optional[int]=40_96     ,							A_:    List[Any]=28     ,							A_:    int=16     ,							A_:    Dict=64     ,							A_:    str=None     ,							A_:    Union[str, Any]="gelu_new"     ,							A_:    Optional[int]=0.0     ,							A_:    Optional[Any]=0.0     ,							A_:    str=0.0     ,							A_:    List[Any]=1E-5     ,							A_:    Tuple=0.02     ,							A_:    int=True     ,							A_:    Optional[int]=5_02_56     ,							A_:    int=5_02_56     ,							A_:    Optional[int]=False     ,							**A_:    Optional[Any]     ,							):
										__lowerCamelCase          =      vocab_size
										__lowerCamelCase          =      n_positions
										__lowerCamelCase          =      n_embd
										__lowerCamelCase          =      n_layer
										__lowerCamelCase          =      n_head
										__lowerCamelCase          =      n_inner
										__lowerCamelCase          =      rotary_dim
										__lowerCamelCase          =      activation_function
										__lowerCamelCase          =      resid_pdrop
										__lowerCamelCase          =      embd_pdrop
										__lowerCamelCase          =      attn_pdrop
										__lowerCamelCase          =      layer_norm_epsilon
										__lowerCamelCase          =      initializer_range
										__lowerCamelCase          =      use_cache

										__lowerCamelCase          =      bos_token_id
										__lowerCamelCase          =      eos_token_id

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




class 			__snake_case   (lowerCamelCase  ):




							def __init__(     self:    Tuple     ,							A_:    PretrainedConfig     ,							A_:    str = "default"     ,							A_:    List[PatchingSpec] = None     ,							A_:    bool = False     ,							):
										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?
													__lowerCamelCase          =      0




							@property
							def   __a   (     self:    List[Any]   ):
										__lowerCamelCase          =      OrderedDict({"""input_ids""": {0: """batch""", 1: """sequence"""}}   )
										if self.use_past:
													self.fill_with_past_key_values_(A_     ,							direction="""inputs"""   )
													__lowerCamelCase          =      {0: """batch""", 1: """past_sequence + sequence"""}
										else:
													__lowerCamelCase          =      {0: """batch""", 1: """sequence"""}

										return common_inputs




							@property
							def   __a   (     self:    Union[str, Any]   ):
										return self._config.n_layer




							@property
							def   __a   (     self:    Tuple   ):
										return self._config.n_head




							def   __a   (     self:    int     ,							A_:    PreTrainedTokenizer     ,							A_:    int = -1     ,							A_:    int = -1     ,							A_:    bool = False     ,							A_:    Optional[TensorType] = None     ,							):
										__lowerCamelCase          =      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()
										__lowerCamelCase          =      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

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

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

										return ordered_inputs




							@property
							def   __a   (     self:    Optional[Any]   ):
										return 13








"""simple docstring"""




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


__magic_name__						: str    =				logging.get_logger(__name__)

__magic_name__						: List[Any]    =				{
    'uclanlp/visualbert-vqa': 'https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json',
    'uclanlp/visualbert-vqa-pre': 'https://huggingface.co/uclanlp/visualbert-vqa-pre/resolve/main/config.json',
    'uclanlp/visualbert-vqa-coco-pre': (
        'https://huggingface.co/uclanlp/visualbert-vqa-coco-pre/resolve/main/config.json'
    ),
    'uclanlp/visualbert-vcr': 'https://huggingface.co/uclanlp/visualbert-vcr/resolve/main/config.json',
    'uclanlp/visualbert-vcr-pre': 'https://huggingface.co/uclanlp/visualbert-vcr-pre/resolve/main/config.json',
    'uclanlp/visualbert-vcr-coco-pre': (
        'https://huggingface.co/uclanlp/visualbert-vcr-coco-pre/resolve/main/config.json'
    ),
    'uclanlp/visualbert-nlvr2': 'https://huggingface.co/uclanlp/visualbert-nlvr2/resolve/main/config.json',
    'uclanlp/visualbert-nlvr2-pre': 'https://huggingface.co/uclanlp/visualbert-nlvr2-pre/resolve/main/config.json',
    'uclanlp/visualbert-nlvr2-coco-pre': (
        'https://huggingface.co/uclanlp/visualbert-nlvr2-coco-pre/resolve/main/config.json'
    )
    # See all VisualBERT models at https://huggingface.co/models?filter=visual_bert
}




class 			__snake_case   (lowerCamelCase  ):
							__a					 =       '''visual_bert'''




							def __init__(     self:    Any     ,							A_:    List[str]=3_05_22     ,							A_:    Tuple=7_68     ,							A_:    Dict=5_12     ,							A_:    List[Any]=12     ,							A_:    str=12     ,							A_:    Dict=30_72     ,							A_:    str="gelu"     ,							A_:    Union[str, Any]=0.1     ,							A_:    Any=0.1     ,							A_:    List[Any]=5_12     ,							A_:    int=2     ,							A_:    int=0.02     ,							A_:    Any=1E-12     ,							A_:    List[str]=False     ,							A_:    str=True     ,							A_:    Union[str, Any]=1     ,							A_:    Optional[int]=0     ,							A_:    Dict=2     ,							**A_:    Optional[int]     ,							):
										super().__init__(pad_token_id=A_     ,							bos_token_id=A_     ,							eos_token_id=A_     ,							**A_   )

										__lowerCamelCase          =      vocab_size
										__lowerCamelCase          =      max_position_embeddings
										__lowerCamelCase          =      hidden_size
										__lowerCamelCase          =      visual_embedding_dim
										__lowerCamelCase          =      num_hidden_layers
										__lowerCamelCase          =      num_attention_heads
										__lowerCamelCase          =      intermediate_size
										__lowerCamelCase          =      hidden_act
										__lowerCamelCase          =      hidden_dropout_prob
										__lowerCamelCase          =      attention_probs_dropout_prob
										__lowerCamelCase          =      initializer_range
										__lowerCamelCase          =      type_vocab_size
										__lowerCamelCase          =      layer_norm_eps
										__lowerCamelCase          =      bypass_transformer
										__lowerCamelCase          =      special_visual_initialize




