"""simple docstring"""






import warnings

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


class     UpperCAmelCase						(_UpperCAmelCase  ):



    """simple docstring"""

    _UpperCAmelCase	:Optional[Any]						    = ["image_processor", "tokenizer"]
    _UpperCAmelCase	:Optional[int]						    = "CLIPImageProcessor"
    _UpperCAmelCase	:Union[str, Any]						    = ("CLIPTokenizer", "CLIPTokenizerFast")






    def __init__(   self    ,			_UpperCAmelCase=None    ,			_UpperCAmelCase=None    ,			**_UpperCAmelCase							):
       lowercase__:   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.'''    ,			_UpperCAmelCase    ,			)
          lowercase__:   Tuple					=      kwargs.pop('''feature_extractor'''							)

       lowercase__:   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__(_UpperCAmelCase    ,			_UpperCAmelCase							)






    def __call__(   self    ,			_UpperCAmelCase=None    ,			_UpperCAmelCase=None    ,			_UpperCAmelCase=None    ,			**_UpperCAmelCase							):

       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:
          lowercase__:   Union[str, Any]					=      self.tokenizer(_UpperCAmelCase    ,			return_tensors=_UpperCAmelCase    ,			**_UpperCAmelCase							)

       if images is not None:
          lowercase__:   Union[str, Any]					=      self.image_processor(_UpperCAmelCase    ,			return_tensors=_UpperCAmelCase    ,			**_UpperCAmelCase							)

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






    def _snake_case			(   self    ,			*_UpperCAmelCase    ,			**_UpperCAmelCase							):
       return self.tokenizer.batch_decode(*_UpperCAmelCase    ,			**_UpperCAmelCase							)






    def _snake_case			(   self    ,			*_UpperCAmelCase    ,			**_UpperCAmelCase							):
       return self.tokenizer.decode(*_UpperCAmelCase    ,			**_UpperCAmelCase							)






    @property
    def _snake_case			(   self							):
       lowercase__:   List[Any]					=      self.tokenizer.model_input_names
       lowercase__:   int					=      self.image_processor.model_input_names
       return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)






    @property
    def _snake_case			(   self							):
       warnings.warn(
           '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''    ,			_UpperCAmelCase    ,			)
       return self.image_processor_class






    @property
    def _snake_case			(   self							):
       warnings.warn(
           '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''    ,			_UpperCAmelCase    ,			)
       return self.image_processor




'''simple docstring'''

a_  :				Any						= """0.21.0"""

from .accelerator import Accelerator
from .big_modeling import (
    cpu_offload,
    cpu_offload_with_hook,
    disk_offload,
    dispatch_model,
    init_empty_weights,
    init_on_device,
    load_checkpoint_and_dispatch,
)
from .data_loader import skip_first_batches
from .launchers import debug_launcher, notebook_launcher
from .state import PartialState
from .utils import (
    DeepSpeedPlugin,
    DistributedDataParallelKwargs,
    DistributedType,
    FullyShardedDataParallelPlugin,
    GradScalerKwargs,
    InitProcessGroupKwargs,
    find_executable_batch_size,
    infer_auto_device_map,
    is_rich_available,
    load_checkpoint_in_model,
    synchronize_rng_states,
)


if is_rich_available():
     from .utils import rich



