





'''simple docstring'''





import copy
import os
from typing import Union

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


_UpperCAmelCase       : Tuple			     =       logging.get_logger(__name__)

_UpperCAmelCase       : List[Any]			     =       {
    """microsoft/git-base""": """https://huggingface.co/microsoft/git-base/resolve/main/config.json""",
}

class      lowerCAmelCase							(      lowerCAmelCase__    ):
 UpperCAmelCase__									=	"git_vision_model"
 def __init__(   self						:   int    ,  UpperCAmelCase						:   Any=768    ,  UpperCAmelCase						:   List[Any]=3072    ,  UpperCAmelCase						:   List[Any]=12    ,  UpperCAmelCase						:   Dict=12    ,  UpperCAmelCase						:   List[Any]=3    ,  UpperCAmelCase						:   Any=224    ,  UpperCAmelCase						:   List[Any]=16    ,  UpperCAmelCase						:   str="quick_gelu"    ,  UpperCAmelCase						:   int=1e-5    ,  UpperCAmelCase						:   Optional[Any]=0.0    ,  UpperCAmelCase						:   Tuple=0.0_2    ,  **UpperCAmelCase						:   List[Any]    ,  )    ->			Optional[Any]:
     super().__init__(**_lowerCamelCase			)

     lowerCamelCase__					:   Union[str, Any]      				=	hidden_size
     lowerCamelCase__					:   Tuple      				=	intermediate_size
     lowerCamelCase__					:   str      				=	num_hidden_layers
     lowerCamelCase__					:   Tuple      				=	num_attention_heads
     lowerCamelCase__					:   Optional[int]      				=	num_channels
     lowerCamelCase__					:   Dict      				=	patch_size
     lowerCamelCase__					:   List[str]      				=	image_size
     lowerCamelCase__					:   str      				=	initializer_range
     lowerCamelCase__					:   Dict      				=	attention_dropout
     lowerCamelCase__					:   Tuple      				=	layer_norm_eps
     lowerCamelCase__					:   Dict      				=	hidden_act







 @classmethod
 def   A_			(   cls						:   str    ,  UpperCAmelCase						:   Optional[int]    ,  **UpperCAmelCase						:   str			)    ->			"PretrainedConfig":
     cls._set_token_in_kwargs(_lowerCamelCase			)

     lowerCamelCase__				,							lowerCamelCase__					:   Dict      				=	cls.get_config_dict(_lowerCamelCase    ,  **_lowerCamelCase			)

     # get the vision config dict if we are loading from GITConfig
     if config_dict.get('model_type'			) == "git":
         lowerCamelCase__					:   Optional[Any]      				=	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(_lowerCamelCase    ,  **_lowerCamelCase			)


class      lowerCAmelCase							(      lowerCAmelCase__    ):
 UpperCAmelCase__									=	"git"
 def __init__(   self						:   List[str]    ,  UpperCAmelCase						:   Union[str, Any]=None    ,  UpperCAmelCase						:   Tuple=30522    ,  UpperCAmelCase						:   int=768    ,  UpperCAmelCase						:   Dict=6    ,  UpperCAmelCase						:   List[str]=12    ,  UpperCAmelCase						:   Optional[int]=3072    ,  UpperCAmelCase						:   List[Any]="gelu"    ,  UpperCAmelCase						:   Optional[int]=0.1    ,  UpperCAmelCase						:   Any=0.1    ,  UpperCAmelCase						:   int=1024    ,  UpperCAmelCase						:   Optional[Any]=0.0_2    ,  UpperCAmelCase						:   int=1e-12    ,  UpperCAmelCase						:   List[str]=0    ,  UpperCAmelCase						:   int="absolute"    ,  UpperCAmelCase						:   Optional[int]=True    ,  UpperCAmelCase						:   Dict=False    ,  UpperCAmelCase						:   Union[str, Any]=101    ,  UpperCAmelCase						:   Dict=102    ,  UpperCAmelCase						:   Optional[Any]=None    ,  **UpperCAmelCase						:   Tuple    ,  )    ->			List[str]:
     super().__init__(bos_token_id=_lowerCamelCase    ,  eos_token_id=_lowerCamelCase    ,  pad_token_id=_lowerCamelCase    ,  **_lowerCamelCase			)

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

     lowerCamelCase__					:   Optional[int]      				=	GitVisionConfig(**_lowerCamelCase			)
     lowerCamelCase__					:   int      				=	vocab_size
     lowerCamelCase__					:   Any      				=	hidden_size
     lowerCamelCase__					:   Any      				=	num_hidden_layers
     lowerCamelCase__					:   Union[str, Any]      				=	num_attention_heads
     lowerCamelCase__					:   Dict      				=	hidden_act
     lowerCamelCase__					:   Optional[int]      				=	intermediate_size
     lowerCamelCase__					:   Union[str, Any]      				=	hidden_dropout_prob
     lowerCamelCase__					:   Dict      				=	attention_probs_dropout_prob
     lowerCamelCase__					:   Tuple      				=	max_position_embeddings
     lowerCamelCase__					:   List[str]      				=	initializer_range
     lowerCamelCase__					:   Dict      				=	layer_norm_eps
     lowerCamelCase__					:   Tuple      				=	position_embedding_type
     lowerCamelCase__					:   str      				=	use_cache
     lowerCamelCase__					:   Tuple      				=	tie_word_embeddings
     lowerCamelCase__					:   Tuple      				=	num_image_with_embedding

     lowerCamelCase__					:   str      				=	bos_token_id
     lowerCamelCase__					:   List[str]      				=	eos_token_id







 def   A_			(   self						:   Union[str, Any]			)    ->			Union[str, Any]:
     lowerCamelCase__					:   Dict      				=	copy.deepcopy(self.__dict__			)
     lowerCamelCase__					:   str      				=	self.vision_config.to_dict()
     lowerCamelCase__					:   int      				=	self.__class__.model_type
     return output












import enum
import shutil
import sys


_UpperCAmelCase     ,_UpperCAmelCase       : List[Any]			     =       shutil.get_terminal_size()

_UpperCAmelCase       : Union[str, Any]			     =       {"""UP""": """A""", """DOWN""": """B""", """RIGHT""": """C""", """LEFT""": """D"""}

class      lowerCAmelCase							(      enum.Enum    ):
 UpperCAmelCase__									=	0
 UpperCAmelCase__									=	1


def  SCREAMING_SNAKE_CASE   ( _UpperCAmelCase		,			_UpperCAmelCase=""				)    ->  int:
    sys.stdout.write(str(_UpperCAmelCase				) + end				)
    sys.stdout.flush()


def  SCREAMING_SNAKE_CASE   ( _UpperCAmelCase		,			_UpperCAmelCase		,			_UpperCAmelCase=""				)    ->  Union[str, Any]:
    forceWrite(F"""\u001b[{color}m{content}\u001b[0m"""		,			_UpperCAmelCase				)


def  SCREAMING_SNAKE_CASE   ( )    ->  Dict:
    forceWrite('\r'				)


def  SCREAMING_SNAKE_CASE   ( _UpperCAmelCase		,			_UpperCAmelCase				)    ->  Optional[Any]:
    forceWrite(F"""\033[{num_lines}{CURSOR_TO_CHAR[direction.upper()]}"""				)


def  SCREAMING_SNAKE_CASE   ( )    ->  int:
    forceWrite(' ' * TERMINAL_WIDTH				)
    reset_cursor()


def  SCREAMING_SNAKE_CASE   ( )    ->  Optional[Any]:
    reset_cursor()
    forceWrite('-' * TERMINAL_WIDTH				)





