

"""simple docstring"""


import warnings

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





class lowerCamelCase__   (				SCREAMING_SNAKE_CASE_    ):



    '''simple docstring'''




    _lowerCamelCase					=   ['''image_processor''', '''tokenizer''']
    _lowerCamelCase					=   '''CLIPImageProcessor'''
    _lowerCamelCase					=   ('''CLIPTokenizer''', '''CLIPTokenizerFast''')




    def __init__( self ,lowerCamelCase_=None ,lowerCamelCase_=None ,**lowerCamelCase_    )    ->      Optional[Any]:
          A				  =		None
          if "feature_extractor" in kwargs:
                warnings.warn(
                    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
                    """ instead.""" ,__a ,)
                A				  =		kwargs.pop("""feature_extractor"""    )

          A				  =		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__(__a ,__a    )




    def __call__( self ,lowerCamelCase_=None ,lowerCamelCase_=None ,lowerCamelCase_=None ,**lowerCamelCase_    )    ->      List[Any]:

          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:
                A				  =		self.tokenizer(__a ,return_tensors=__a ,**__a    )

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

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




    def UpperCamelCase__		( self ,*lowerCamelCase_ ,**lowerCamelCase_    )    ->      Union[str, Any]:
          return self.tokenizer.batch_decode(*__a ,**__a    )




    def UpperCamelCase__		( self ,*lowerCamelCase_ ,**lowerCamelCase_    )    ->      int:
          return self.tokenizer.decode(*__a ,**__a    )




    @property
    def UpperCamelCase__		( self    )    ->      Optional[Any]:
          A				  =		self.tokenizer.model_input_names
          A				  =		self.image_processor.model_input_names
          return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names    )    )




    @property
    def UpperCamelCase__		( self    )    ->      Any:
          warnings.warn(
              """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.""" ,__a ,)
          return self.image_processor_class




    @property
    def UpperCamelCase__		( self    )    ->      Optional[Any]:
          warnings.warn(
              """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.""" ,__a ,)
          return self.image_processor









'''simple docstring'''





from typing import TYPE_CHECKING

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


A__    :   List[str]           =					{
    '''configuration_autoformer''': [
        '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''AutoformerConfig''',
    ],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    A__    :   Optional[Any]           =					[
        '''AUTOFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
        '''AutoformerForPrediction''',
        '''AutoformerModel''',
        '''AutoformerPreTrainedModel''',
    ]


if TYPE_CHECKING:
    from .configuration_autoformer import (
        AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
        AutoformerConfig,
    )

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_autoformer import (
            AUTOFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
            AutoformerForPrediction,
            AutoformerModel,
            AutoformerPreTrainedModel,
        )

else:
    import sys

    A__    :   Optional[int]           =					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



