


import warnings

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





class  lowerCAmelCase__(    UpperCamelCase__						):






    '''simple docstring'''





    A_  :     List[Any]			= ['image_processor', 'tokenizer']
    A_  :     Union[str, Any]			= 'CLIPImageProcessor'
    A_  :     Tuple			= ('XLMRobertaTokenizer', 'XLMRobertaTokenizerFast')





    def __init__(	self				:   Optional[int]       ,   __snake_case				:   Dict=None       ,   __snake_case				:   str=None       ,   **__snake_case				:   str	):





       '''simple docstring'''
       UpperCAmelCase_							:      Dict						=   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       ,   )
          UpperCAmelCase_							:      Any						=   kwargs.pop('''feature_extractor'''	)

       UpperCAmelCase_							:      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__(__A       ,   __A	)





    def __call__(	self				:   Any       ,   __snake_case				:   Dict=None       ,   __snake_case				:   List[str]=None       ,   __snake_case				:   int=None       ,   **__snake_case				:   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:
          UpperCAmelCase_							:      Any						=   self.tokenizer(__A       ,   return_tensors=__A       ,   **__A	)

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

       if text is not None and images is not None:
          UpperCAmelCase_							:      List[Any]						=   image_features.pixel_values
          return encoding
       elif text is not None:
          return encoding
       else:
          return BatchEncoding(data=dict(**__A	)       ,   tensor_type=__A	)





    def 					_lowerCamelCase (	self				:   Union[str, Any]       ,   *__snake_case				:   List[Any]       ,   **__snake_case				:   Optional[int]	):





       '''simple docstring'''
       return self.tokenizer.batch_decode(*__A       ,   **__A	)





    def 					_lowerCamelCase (	self				:   Union[str, Any]       ,   *__snake_case				:   Dict       ,   **__snake_case				:   Tuple	):





       '''simple docstring'''
       return self.tokenizer.decode(*__A       ,   **__A	)





    @property
    def 					_lowerCamelCase (	self				:   int	):





       '''simple docstring'''
       UpperCAmelCase_							:      Tuple						=   self.tokenizer.model_input_names
       UpperCAmelCase_							:      int						=   self.image_processor.model_input_names
       return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names	)	)




# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

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


__UpperCamelCase				:  List[Any]      					=							{
    'configuration_vivit': ['VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VivitConfig'],
}
try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __UpperCamelCase				:  Optional[Any]      					=							['VivitImageProcessor']


try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __UpperCamelCase				:  List[Any]      					=							[
           'VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST',
           'VivitModel',
           'VivitPreTrainedModel',
           'VivitForVideoClassification',
       ]


if TYPE_CHECKING:
       from .configuration_vivit import VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, VivitConfig

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .image_processing_vivit import VivitImageProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_vivit import (
                  VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  VivitForVideoClassification,
                  VivitModel,
                  VivitPreTrainedModel,
              )


else:
       import sys

       __UpperCamelCase				:  str      					=							_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)