

'''simple docstring'''



from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCAmelCase					:			Union[str, Any]       =	logging.get_logger(__name__)

UpperCAmelCase					:			Union[str, Any]       =	{
    'facebook/data2vec-vision-base-ft': (
        'https://huggingface.co/facebook/data2vec-vision-base-ft/resolve/main/config.json'
    ),
}







class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""



 lowerCAmelCase__       = "data2vec-vision"
 def __init__(						self   :			Dict   ,				__SCREAMING_SNAKE_CASE   :			List[Any]=768   ,				__SCREAMING_SNAKE_CASE   :			Optional[int]=12   ,				__SCREAMING_SNAKE_CASE   :			Optional[int]=12   ,				__SCREAMING_SNAKE_CASE   :			Dict=3_072   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]="gelu"   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=0.0   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=0.0   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=0.02   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=1E-12   ,				__SCREAMING_SNAKE_CASE   :			Dict=224   ,				__SCREAMING_SNAKE_CASE   :			Tuple=16   ,				__SCREAMING_SNAKE_CASE   :			Any=3   ,				__SCREAMING_SNAKE_CASE   :			int=False   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=False   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=False   ,				__SCREAMING_SNAKE_CASE   :			Dict=False   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=0.1   ,				__SCREAMING_SNAKE_CASE   :			Dict=0.1   ,				__SCREAMING_SNAKE_CASE   :			str=True   ,				__SCREAMING_SNAKE_CASE   :			Optional[int]=[3, 5, 7, 11]   ,				__SCREAMING_SNAKE_CASE   :			List[Any]=[1, 2, 3, 6]   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=True   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=0.4   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=256   ,				__SCREAMING_SNAKE_CASE   :			List[Any]=1   ,				__SCREAMING_SNAKE_CASE   :			Dict=False   ,				__SCREAMING_SNAKE_CASE   :			Optional[int]=255   ,				**__SCREAMING_SNAKE_CASE   :			int   ,				)    ->					Optional[Any]:


      """simple docstring"""




      super().__init__(**__SCREAMING_SNAKE_CASE     )

      __SCREAMING_SNAKE_CASE      = hidden_size
      __SCREAMING_SNAKE_CASE      = num_hidden_layers
      __SCREAMING_SNAKE_CASE      = num_attention_heads
      __SCREAMING_SNAKE_CASE      = intermediate_size
      __SCREAMING_SNAKE_CASE      = hidden_act
      __SCREAMING_SNAKE_CASE      = hidden_dropout_prob
      __SCREAMING_SNAKE_CASE      = attention_probs_dropout_prob
      __SCREAMING_SNAKE_CASE      = initializer_range
      __SCREAMING_SNAKE_CASE      = layer_norm_eps

      __SCREAMING_SNAKE_CASE      = image_size
      __SCREAMING_SNAKE_CASE      = patch_size
      __SCREAMING_SNAKE_CASE      = num_channels
      __SCREAMING_SNAKE_CASE      = use_mask_token
      __SCREAMING_SNAKE_CASE      = use_absolute_position_embeddings
      __SCREAMING_SNAKE_CASE      = use_relative_position_bias
      __SCREAMING_SNAKE_CASE      = use_shared_relative_position_bias
      __SCREAMING_SNAKE_CASE      = layer_scale_init_value
      __SCREAMING_SNAKE_CASE      = drop_path_rate
      __SCREAMING_SNAKE_CASE      = use_mean_pooling
      # decode head attributes (semantic segmentation)
      __SCREAMING_SNAKE_CASE      = out_indices
      __SCREAMING_SNAKE_CASE      = pool_scales
      # auxiliary head attributes (semantic segmentation)
      __SCREAMING_SNAKE_CASE      = use_auxiliary_head
      __SCREAMING_SNAKE_CASE      = auxiliary_loss_weight
      __SCREAMING_SNAKE_CASE      = auxiliary_channels
      __SCREAMING_SNAKE_CASE      = auxiliary_num_convs
      __SCREAMING_SNAKE_CASE      = auxiliary_concat_input
      __SCREAMING_SNAKE_CASE      = semantic_loss_ignore_index







class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""



 lowerCAmelCase__       = version.parse("1.11"   )
 @property
 def  UpperCAmelCase__						(						self   :			Dict     )    ->					Mapping[str, Mapping[int, str]]:


      """simple docstring"""




      return OrderedDict(
          [
              ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
          ]     )


 @property
 def  UpperCAmelCase__						(						self   :			str     )    ->					float:


      """simple docstring"""




      return 1E-4









'''simple docstring'''



import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding







class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""



 lowerCAmelCase__       = ["image_processor", "tokenizer"]
 lowerCAmelCase__       = "CLIPImageProcessor"
 lowerCAmelCase__       = ("XLMRobertaTokenizer", "XLMRobertaTokenizerFast")
 def __init__(						self   :			Optional[Any]   ,				__SCREAMING_SNAKE_CASE   :			Any=None   ,				__SCREAMING_SNAKE_CASE   :			str=None   ,				**__SCREAMING_SNAKE_CASE   :			Tuple     )    ->					Dict:


      """simple docstring"""




      __SCREAMING_SNAKE_CASE      = None
      if "feature_extractor" in kwargs:
           warnings.warn(
               """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
               """ instead."""   ,				__SCREAMING_SNAKE_CASE   ,				)
           __SCREAMING_SNAKE_CASE      = kwargs.pop("""feature_extractor"""     )

      __SCREAMING_SNAKE_CASE      = image_processor if image_processor is not None else feature_extractor
      if image_processor is None:
           raise ValueError("""You need to specify an `image_processor`."""     )
      if tokenizer is None:
           raise ValueError("""You need to specify a `tokenizer`."""     )

      super().__init__(__SCREAMING_SNAKE_CASE   ,				__SCREAMING_SNAKE_CASE     )
 def __call__(						self   :			Union[str, Any]   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=None   ,				__SCREAMING_SNAKE_CASE   :			Any=None   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=None   ,				**__SCREAMING_SNAKE_CASE   :			str     )    ->					int:


      """simple docstring"""




      if text is None and images is None:
           raise ValueError("""You have to specify either text or images. Both cannot be none."""     )

      if text is not None:
           __SCREAMING_SNAKE_CASE      = self.tokenizer(__SCREAMING_SNAKE_CASE   ,				return_tensors=__SCREAMING_SNAKE_CASE   ,				**__SCREAMING_SNAKE_CASE     )

      if images is not None:
           __SCREAMING_SNAKE_CASE      = self.image_processor(__SCREAMING_SNAKE_CASE   ,				return_tensors=__SCREAMING_SNAKE_CASE   ,				**__SCREAMING_SNAKE_CASE     )

      if text is not None and images is not None:
           __SCREAMING_SNAKE_CASE      = image_features.pixel_values
           return encoding
      elif text is not None:
           return encoding
      else:
           return BatchEncoding(data=dict(**__SCREAMING_SNAKE_CASE     )   ,				tensor_type=__SCREAMING_SNAKE_CASE     )
 def  UpperCAmelCase__						(						self   :			List[str]   ,				*__SCREAMING_SNAKE_CASE   :			Tuple   ,				**__SCREAMING_SNAKE_CASE   :			List[Any]     )    ->					Optional[int]:


      """simple docstring"""




      return self.tokenizer.batch_decode(*__SCREAMING_SNAKE_CASE   ,				**__SCREAMING_SNAKE_CASE     )
 def  UpperCAmelCase__						(						self   :			List[Any]   ,				*__SCREAMING_SNAKE_CASE   :			Union[str, Any]   ,				**__SCREAMING_SNAKE_CASE   :			str     )    ->					Optional[Any]:


      """simple docstring"""




      return self.tokenizer.decode(*__SCREAMING_SNAKE_CASE   ,				**__SCREAMING_SNAKE_CASE     )


 @property
 def  UpperCAmelCase__						(						self   :			List[Any]     )    ->					List[Any]:


      """simple docstring"""




      __SCREAMING_SNAKE_CASE      = self.tokenizer.model_input_names
      __SCREAMING_SNAKE_CASE      = self.image_processor.model_input_names
      return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names     )     )






