import warnings
from typing import List, Optional, Union

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType


class 			UpperCAmelCase__    (		snake_case					):



  """simple docstring"""






  lowerCAmelCase__		:	Tuple    		= ['image_processor', 'tokenizer']
  lowerCAmelCase__		:	str    		= 'ViltImageProcessor'
  lowerCAmelCase__		:	str    		= ('BertTokenizer', 'BertTokenizerFast')






  def __init__(				self:			Tuple				,				__lowerCAmelCase:			Optional[int]=None				,				__lowerCAmelCase:			Union[str, Any]=None				,				**__lowerCAmelCase:			Dict   ) -> Optional[int]:




    '''simple docstring'''




    __UpperCAmelCase						    =       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				,				)
      __UpperCAmelCase						    =       kwargs.pop("feature_extractor"   )

    __UpperCAmelCase						    =       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   )
    __UpperCAmelCase						    =       self.image_processor






  def __call__(				self:			str				,				__lowerCAmelCase:			Dict				,				__lowerCAmelCase:			Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None				,				__lowerCAmelCase:			bool = True				,				__lowerCAmelCase:			Union[bool, str, PaddingStrategy] = False				,				__lowerCAmelCase:			Union[bool, str, TruncationStrategy] = None				,				__lowerCAmelCase:			Optional[int] = None				,				__lowerCAmelCase:			int = 0				,				__lowerCAmelCase:			Optional[int] = None				,				__lowerCAmelCase:			Optional[bool] = None				,				__lowerCAmelCase:			Optional[bool] = None				,				__lowerCAmelCase:			bool = False				,				__lowerCAmelCase:			bool = False				,				__lowerCAmelCase:			bool = False				,				__lowerCAmelCase:			bool = False				,				__lowerCAmelCase:			bool = True				,				__lowerCAmelCase:			Optional[Union[str, TensorType]] = None				,				**__lowerCAmelCase:			Dict				,				) -> BatchEncoding:




    '''simple docstring'''




    __UpperCAmelCase						    =       self.tokenizer(
        text=__lowerCAmelCase				,				add_special_tokens=__lowerCAmelCase				,				padding=__lowerCAmelCase				,				truncation=__lowerCAmelCase				,				max_length=__lowerCAmelCase				,				stride=__lowerCAmelCase				,				pad_to_multiple_of=__lowerCAmelCase				,				return_token_type_ids=__lowerCAmelCase				,				return_attention_mask=__lowerCAmelCase				,				return_overflowing_tokens=__lowerCAmelCase				,				return_special_tokens_mask=__lowerCAmelCase				,				return_offsets_mapping=__lowerCAmelCase				,				return_length=__lowerCAmelCase				,				verbose=__lowerCAmelCase				,				return_tensors=__lowerCAmelCase				,				**__lowerCAmelCase				,				)
    # add pixel_values + pixel_mask
    __UpperCAmelCase						    =       self.image_processor(__lowerCAmelCase				,				return_tensors=__lowerCAmelCase   )
    encoding.update(__lowerCAmelCase   )

    return encoding






  def 	_UpperCAmelCase				(				self:			Optional[int]				,				*__lowerCAmelCase:			List[str]				,				**__lowerCAmelCase:			Union[str, Any]   ) -> List[str]:




    '''simple docstring'''




    return self.tokenizer.batch_decode(*__lowerCAmelCase				,				**__lowerCAmelCase   )






  def 	_UpperCAmelCase				(				self:			int				,				*__lowerCAmelCase:			int				,				**__lowerCAmelCase:			List[str]   ) -> str:




    '''simple docstring'''




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






  @property
  def 	_UpperCAmelCase				(				self:			Optional[int]   ) -> Union[str, Any]:




    '''simple docstring'''




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






  @property
  def 	_UpperCAmelCase				(				self:			Union[str, Any]   ) -> Dict:




    '''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 	_UpperCAmelCase				(				self:			Union[str, Any]   ) -> str:




    '''simple docstring'''




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




import warnings

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


class 			UpperCAmelCase__    (		snake_case					):



  """simple docstring"""






  lowerCAmelCase__		:	Optional[int]    		= ['image_processor', 'tokenizer']
  lowerCAmelCase__		:	Any    		= 'CLIPImageProcessor'
  lowerCAmelCase__		:	Any    		= ('CLIPTokenizer', 'CLIPTokenizerFast')






  def __init__(				self:			str				,				__lowerCAmelCase:			List[Any]=None				,				__lowerCAmelCase:			Any=None				,				**__lowerCAmelCase:			str   ) -> Optional[int]:




    '''simple docstring'''




    __UpperCAmelCase						    =       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				,				)
      __UpperCAmelCase						    =       kwargs.pop("feature_extractor"   )

    __UpperCAmelCase						    =       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:			Optional[int]				,				__lowerCAmelCase:			Union[str, Any]=None				,				__lowerCAmelCase:			Dict=None				,				__lowerCAmelCase:			Optional[int]=None				,				**__lowerCAmelCase:			Optional[int]   ) -> Dict:




    '''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:
      __UpperCAmelCase						    =       self.tokenizer(__lowerCAmelCase				,				return_tensors=__lowerCAmelCase				,				**__lowerCAmelCase   )

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

    if text is not None and images is not None:
      __UpperCAmelCase						    =       image_features.pixel_values
      return encoding
    elif text is not None:
      return encoding
    else:
      return BatchEncoding(data=dict(**__lowerCAmelCase   )				,				tensor_type=__lowerCAmelCase   )






  def 	_UpperCAmelCase				(				self:			str				,				*__lowerCAmelCase:			str				,				**__lowerCAmelCase:			List[Any]   ) -> Optional[Any]:




    '''simple docstring'''




    return self.tokenizer.batch_decode(*__lowerCAmelCase				,				**__lowerCAmelCase   )






  def 	_UpperCAmelCase				(				self:			Any				,				*__lowerCAmelCase:			List[Any]				,				**__lowerCAmelCase:			Dict   ) -> Union[str, Any]:




    '''simple docstring'''




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






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




    '''simple docstring'''




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






  @property
  def 	_UpperCAmelCase				(				self:			Optional[int]   ) -> str:




    '''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 	_UpperCAmelCase				(				self:			List[Any]   ) -> List[str]:




    '''simple docstring'''




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



