






import warnings

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







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    ['''image_processor''', '''tokenizer''']
      A          =    '''CLIPImageProcessor'''
      A          =    ('''CLIPTokenizer''', '''CLIPTokenizerFast''')
      def __init__(   self    ,	_lowerCAmelCase=None    ,	_lowerCAmelCase=None    ,	**_lowerCAmelCase		):



          '''simple docstring'''
          lowerCAmelCase__   :Any      							=				None
          if "feature_extractor" in kwargs:
              warnings.warn(
                  "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
                  " instead."    ,	_lowerCAmelCase    ,	)
              lowerCAmelCase__   :int      							=				kwargs.pop("feature_extractor"		)

          lowerCAmelCase__   :Any      							=				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__(_lowerCAmelCase    ,	_lowerCAmelCase		)
      def __call__(   self    ,	_lowerCAmelCase=None    ,	_lowerCAmelCase=None    ,	_lowerCAmelCase=None    ,	**_lowerCAmelCase		):



          '''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:
              lowerCAmelCase__   :Optional[Any]      							=				self.tokenizer(_lowerCAmelCase    ,	return_tensors=_lowerCAmelCase    ,	**_lowerCAmelCase		)

          if images is not None:
              lowerCAmelCase__   :str      							=				self.image_processor(_lowerCAmelCase    ,	return_tensors=_lowerCAmelCase    ,	**_lowerCAmelCase		)

          if text is not None and images is not None:
              lowerCAmelCase__   :int      							=				image_features.pixel_values
              return encoding
          elif text is not None:
              return encoding
          else:
              return BatchEncoding(data=dict(**_lowerCAmelCase		)    ,	tensor_type=_lowerCAmelCase		)
      def 			snake_case_      (   self    ,	*_lowerCAmelCase    ,	**_lowerCAmelCase		):



          '''simple docstring'''
          return self.tokenizer.batch_decode(*_lowerCAmelCase    ,	**_lowerCAmelCase		)
      def 			snake_case_      (   self    ,	*_lowerCAmelCase    ,	**_lowerCAmelCase		):



          '''simple docstring'''
          return self.tokenizer.decode(*_lowerCAmelCase    ,	**_lowerCAmelCase		)
      @property
      def 			snake_case_      (   self		):



          '''simple docstring'''
          lowerCAmelCase__   :List[Any]      							=				self.tokenizer.model_input_names
          lowerCAmelCase__   :Optional[int]      							=				self.image_processor.model_input_names
          return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names		)		)
      @property
      def 			snake_case_      (   self		):



          '''simple docstring'''
          warnings.warn(
              "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."    ,	_lowerCAmelCase    ,	)
          return self.image_processor_class



      @property
      def 			snake_case_      (   self		):



          '''simple docstring'''
          warnings.warn(
              "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."    ,	_lowerCAmelCase    ,	)
          return self.image_processor











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


_a    :   Tuple        =			logging.get_logger(__name__)

_a    :   Optional[int]        =			{
    """facebook/levit-128S""": """https://huggingface.co/facebook/levit-128S/resolve/main/config.json""",
    # See all LeViT models at https://huggingface.co/models?filter=levit
}







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    '''levit'''
      def __init__(   self    ,	_lowerCAmelCase=224    ,	_lowerCAmelCase=3    ,	_lowerCAmelCase=3    ,	_lowerCAmelCase=2    ,	_lowerCAmelCase=1    ,	_lowerCAmelCase=16    ,	_lowerCAmelCase=[128, 256, 384]    ,	_lowerCAmelCase=[4, 8, 12]    ,	_lowerCAmelCase=[4, 4, 4]    ,	_lowerCAmelCase=[16, 16, 16]    ,	_lowerCAmelCase=0    ,	_lowerCAmelCase=[2, 2, 2]    ,	_lowerCAmelCase=[2, 2, 2]    ,	_lowerCAmelCase=0.02    ,	**_lowerCAmelCase    ,	):



          '''simple docstring'''
          super().__init__(**_lowerCAmelCase		)
          lowerCAmelCase__   :List[str]      							=				image_size
          lowerCAmelCase__   :Dict      							=				num_channels
          lowerCAmelCase__   :List[Any]      							=				kernel_size
          lowerCAmelCase__   :List[Any]      							=				stride
          lowerCAmelCase__   :Tuple      							=				padding
          lowerCAmelCase__   :str      							=				hidden_sizes
          lowerCAmelCase__   :Union[str, Any]      							=				num_attention_heads
          lowerCAmelCase__   :Optional[int]      							=				depths
          lowerCAmelCase__   :Union[str, Any]      							=				key_dim
          lowerCAmelCase__   :str      							=				drop_path_rate
          lowerCAmelCase__   :int      							=				patch_size
          lowerCAmelCase__   :Dict      							=				attention_ratio
          lowerCAmelCase__   :Dict      							=				mlp_ratio
          lowerCAmelCase__   :Optional[int]      							=				initializer_range
          lowerCAmelCase__   :Tuple      							=				[
              ["Subsample", key_dim[0], hidden_sizes[0] // key_dim[0], 4, 2, 2],
              ["Subsample", key_dim[0], hidden_sizes[1] // key_dim[0], 4, 2, 2],
          ]







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    version.parse('''1.11'''		)
      @property
      def 			snake_case_      (   self		):



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



      @property
      def 			snake_case_      (   self		):



          '''simple docstring'''
          return 1e-4



