


'''simple docstring'''
import copy
import os
from typing import Union

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


UpperCamelCase__    					=      logging.get_logger(__name__)

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




class 			lowerCamelCase_   (	__a      ):
      lowerCAmelCase__		     =     'git_vision_model'






      def __init__(					self				:    int						,						_A				:    str=768						,						_A				:    Any=3_072						,						_A				:    Union[str, Any]=12						,						_A				:    Dict=12						,						_A				:    List[str]=3						,						_A				:    Union[str, Any]=224						,						_A				:    str=16						,						_A				:    int="quick_gelu"						,						_A				:    List[str]=1e-5						,						_A				:    Union[str, Any]=0.0						,						_A				:    int=0.0_2						,						**_A				:    List[str]						,						):


          '''simple docstring'''


          super().__init__(**_A )

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






      @classmethod
      def lowercase_							(					cls				:    List[Any]						,						_A				:    Union[str, os.PathLike]						,						**_A				:    Optional[int] ):


          '''simple docstring'''


          cls._set_token_in_kwargs(_A )

          UpperCAmelCase__						,						UpperCAmelCase__			:		List[str]													=				cls.get_config_dict(_A						,						**_A )

          # get the vision config dict if we are loading from GITConfig
          if config_dict.get('''model_type''' ) == "git":
              UpperCAmelCase__			:		int													=				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(_A						,						**_A )




class 			lowerCamelCase_   (	__a      ):
      lowerCAmelCase__		     =     'git'






      def __init__(					self				:    int						,						_A				:    List[str]=None						,						_A				:    Any=30_522						,						_A				:    Tuple=768						,						_A				:    Optional[Any]=6						,						_A				:    Optional[int]=12						,						_A				:    Union[str, Any]=3_072						,						_A				:    List[Any]="gelu"						,						_A				:    List[Any]=0.1						,						_A				:    Tuple=0.1						,						_A				:    Union[str, Any]=1_024						,						_A				:    Union[str, Any]=0.0_2						,						_A				:    List[Any]=1e-12						,						_A				:    int=0						,						_A				:    Tuple="absolute"						,						_A				:    str=True						,						_A				:    List[Any]=False						,						_A				:    List[Any]=101						,						_A				:    Any=102						,						_A				:    Optional[Any]=None						,						**_A				:    int						,						):


          '''simple docstring'''


          super().__init__(bos_token_id=_A						,						eos_token_id=_A						,						pad_token_id=_A						,						**_A )

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

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

          UpperCAmelCase__			:		List[Any]													=				bos_token_id
          UpperCAmelCase__			:		List[str]													=				eos_token_id






      def lowercase_							(					self				:    List[Any] ):


          '''simple docstring'''


          UpperCAmelCase__			:		Optional[Any]													=				copy.deepcopy(self.__dict__ )
          UpperCAmelCase__			:		str													=				self.vision_config.to_dict()
          UpperCAmelCase__			:		Any													=				self.__class__.model_type
          return output




'''simple docstring'''
# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


UpperCamelCase__    					=      {
    '''configuration_vivit''': ['''VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''VivitConfig'''],
}
try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      ['''VivitImageProcessor''']


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCamelCase__    					=      [
      '''VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''VivitModel''',
      '''VivitPreTrainedModel''',
      '''VivitForVideoClassification''',
  ]


if TYPE_CHECKING:
  from .configuration_vivit import VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, VivitConfig

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .image_processing_vivit import VivitImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_vivit import (
        VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
        VivitForVideoClassification,
        VivitModel,
        VivitPreTrainedModel,
    )


else:
  import sys

  UpperCamelCase__    					=      _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)
