



"""simple docstring"""


import copy
import os
from typing import Union

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


snake_case_    					=	logging.get_logger(__name__)

snake_case_    					=	{
    """microsoft/git-base""": """https://huggingface.co/microsoft/git-base/resolve/main/config.json""",
}







class 				A_      (					SCREAMING_SNAKE_CASE_    ):



						"""simple docstring"""
						__UpperCamelCase		    =							"""git_vision_model"""






						def __init__( self			:str       ,  lowercase_			:Union[str, Any]=7_68       ,  lowercase_			:Optional[Any]=30_72       ,  lowercase_			:Optional[Any]=12       ,  lowercase_			:Union[str, Any]=12       ,  lowercase_			:List[Any]=3       ,  lowercase_			:Dict=2_24       ,  lowercase_			:List[Any]=16       ,  lowercase_			:str="quick_gelu"       ,  lowercase_			:Dict=1E-5       ,  lowercase_			:Optional[Any]=0.0       ,  lowercase_			:Union[str, Any]=0.02       ,  **lowercase_			:int       ,  )    ->      Tuple:
												super().__init__(**lowercase_ )

												UpperCAmelCase					=			hidden_size
												UpperCAmelCase					=			intermediate_size
												UpperCAmelCase					=			num_hidden_layers
												UpperCAmelCase					=			num_attention_heads
												UpperCAmelCase					=			num_channels
												UpperCAmelCase					=			patch_size
												UpperCAmelCase					=			image_size
												UpperCAmelCase					=			initializer_range
												UpperCAmelCase					=			attention_dropout
												UpperCAmelCase					=			layer_norm_eps
												UpperCAmelCase					=			hidden_act






						@classmethod
						def      UpperCAmelCase__					( cls			:List[str]       ,  lowercase_			:Union[str, os.PathLike]       ,  **lowercase_			:Dict )    ->      "PretrainedConfig":
												cls._set_token_in_kwargs(lowercase_ )

												UpperCAmelCase				,   UpperCAmelCase					=			cls.get_config_dict(lowercase_       ,  **lowercase_ )

												# get the vision config dict if we are loading from GITConfig
												if config_dict.get('model_type' ) == "git":
																		UpperCAmelCase					=			config_dict['vision_config']

												if "model_type" in config_dict and hasattr(cls       ,  'model_type' ) and config_dict["model_type"] != cls.model_type:
																		logger.warning(
																		    f"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
																		    f"""{cls.model_type}. This is not supported for all configurations of models and can yield errors.""" )

												return cls.from_dict(lowercase_       ,  **lowercase_ )







class 				A_      (					SCREAMING_SNAKE_CASE_    ):



						"""simple docstring"""
						__UpperCamelCase		    =							"""git"""






						def __init__( self			:str       ,  lowercase_			:Optional[Any]=None       ,  lowercase_			:List[str]=3_05_22       ,  lowercase_			:Any=7_68       ,  lowercase_			:List[str]=6       ,  lowercase_			:Dict=12       ,  lowercase_			:Optional[int]=30_72       ,  lowercase_			:Union[str, Any]="gelu"       ,  lowercase_			:Any=0.1       ,  lowercase_			:List[Any]=0.1       ,  lowercase_			:List[Any]=10_24       ,  lowercase_			:Optional[int]=0.02       ,  lowercase_			:Any=1E-12       ,  lowercase_			:Union[str, Any]=0       ,  lowercase_			:List[str]="absolute"       ,  lowercase_			:Tuple=True       ,  lowercase_			:List[str]=False       ,  lowercase_			:Optional[int]=1_01       ,  lowercase_			:List[str]=1_02       ,  lowercase_			:Tuple=None       ,  **lowercase_			:Dict       ,  )    ->      Tuple:
												super().__init__(bos_token_id=lowercase_       ,  eos_token_id=lowercase_       ,  pad_token_id=lowercase_       ,  **lowercase_ )

												if vision_config is None:
																		UpperCAmelCase					=			{}
																		logger.info('vision_config is None. initializing the GitVisionConfig with default values.' )

												UpperCAmelCase					=			GitVisionConfig(**lowercase_ )
												UpperCAmelCase					=			vocab_size
												UpperCAmelCase					=			hidden_size
												UpperCAmelCase					=			num_hidden_layers
												UpperCAmelCase					=			num_attention_heads
												UpperCAmelCase					=			hidden_act
												UpperCAmelCase					=			intermediate_size
												UpperCAmelCase					=			hidden_dropout_prob
												UpperCAmelCase					=			attention_probs_dropout_prob
												UpperCAmelCase					=			max_position_embeddings
												UpperCAmelCase					=			initializer_range
												UpperCAmelCase					=			layer_norm_eps
												UpperCAmelCase					=			position_embedding_type
												UpperCAmelCase					=			use_cache
												UpperCAmelCase					=			tie_word_embeddings
												UpperCAmelCase					=			num_image_with_embedding

												UpperCAmelCase					=			bos_token_id
												UpperCAmelCase					=			eos_token_id






						def      UpperCAmelCase__					( self			:Any )    ->      Dict:
												UpperCAmelCase					=			copy.deepcopy(self.__dict__ )
												UpperCAmelCase					=			self.vision_config.to_dict()
												UpperCAmelCase					=			self.__class__.model_type
												return output










"""simple docstring"""


import operator as op


snake_case_    					=	"""scaler.pt"""
snake_case_    					=	"""pytorch_model"""
snake_case_    					=	"""random_states"""
snake_case_    					=	"""optimizer"""
snake_case_    					=	"""scheduler"""
snake_case_    					=	"""pytorch_model.bin"""
snake_case_    					=	"""pytorch_model.bin.index.json"""
snake_case_    					=	"""model.safetensors"""
snake_case_    					=	"""model.safetensors.index.json"""
snake_case_    					=	"""1.10.2"""
snake_case_    					=	"""py38"""
snake_case_    					=	"""4.17.0"""
snake_case_    					=	["""ml.p3.16xlarge""", """ml.p3dn.24xlarge""", """ml.p4dn.24xlarge"""]
snake_case_    					=	["""FULL_SHARD""", """SHARD_GRAD_OP""", """NO_SHARD""", """HYBRID_SHARD""", """HYBRID_SHARD_ZERO2"""]
snake_case_    					=	["""TRANSFORMER_BASED_WRAP""", """SIZE_BASED_WRAP""", """NO_WRAP"""]
snake_case_    					=	["""BACKWARD_PRE""", """BACKWARD_POST""", """NO_PREFETCH"""]
snake_case_    					=	["""FULL_STATE_DICT""", """LOCAL_STATE_DICT""", """SHARDED_STATE_DICT"""]
snake_case_    					=	"""2.0.1"""
snake_case_    					=	["""pdsh""", """standard""", """openmpi""", """mvapich"""]
snake_case_    					=	["""default""", """reduce-overhead""", """max-autotune"""]

snake_case_    					=	{""">""": op.gt, """>=""": op.ge, """==""": op.eq, """!=""": op.ne, """<=""": op.le, """<""": op.lt}

# These are the args for `torch.distributed.launch` for pytorch < 1.9
snake_case_    					=	[
    """nnodes""",
    """nproc_per_node""",
    """rdzv_backend""",
    """rdzv_endpoint""",
    """rdzv_id""",
    """rdzv_conf""",
    """standalone""",
    """max_restarts""",
    """monitor_interval""",
    """start_method""",
    """role""",
    """module""",
    """m""",
    """no_python""",
    """run_path""",
    """log_dir""",
    """r""",
    """redirects""",
    """t""",
    """tee""",
    """node_rank""",
    """master_addr""",
    """master_port""",
]

snake_case_    					=	["""DEEPSPEED""", """MULTI_GPU""", """FSDP""", """MEGATRON_LM"""]
snake_case_    					=	["""DEEPSPEED""", """MULTI_XPU""", """FSDP"""]





