


'''simple docstring'''

import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class _lowerCamelCase       (						lowerCAmelCase__							):



		'''simple docstring'''







		A_	:			Any          =				["""image_processor""", """tokenizer"""]
		A_	:			Optional[Any]          =				"""ViTImageProcessor"""
		A_	:			Any          =				("""CLIPTokenizer""", """CLIPTokenizerFast""")







		def __init__(					self		:						Optional[int]  ,     _A		:						Any=None  ,     _A		:						str=None  ,     **_A		:						Tuple			)  -> int:
			__magic_name__       :    Tuple     	=     None
			if "feature_extractor" in kwargs:
				warnings.warn(
				    'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
				    ' instead.'  ,     lowercase_  ,     )
				__magic_name__       :    Tuple     	=     kwargs.pop('feature_extractor'			)

			__magic_name__       :    int     	=     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__(lowercase_  ,     lowercase_			)







		def __call__(					self		:						Tuple  ,     _A		:						Dict=None  ,     _A		:						Union[str, Any]=None  ,     _A		:						List[str]=None  ,     _A		:						str=None  ,     **_A		:						Union[str, Any]			)  -> int:
			if text is None and visual_prompt is None and images is None:
				raise ValueError('You have to specify either text, visual prompt or images.'			)

			if text is not None and visual_prompt is not None:
				raise ValueError('You have to specify exactly one type of prompt. Either text or visual prompt.'			)

			if text is not None:
				__magic_name__       :    Tuple     	=     self.tokenizer(lowercase_  ,     return_tensors=lowercase_  ,     **lowercase_			)

			if visual_prompt is not None:
				__magic_name__       :    Tuple     	=     self.image_processor(lowercase_  ,     return_tensors=lowercase_  ,     **lowercase_			)

			if images is not None:
				__magic_name__       :    Tuple     	=     self.image_processor(lowercase_  ,     return_tensors=lowercase_  ,     **lowercase_			)

			if visual_prompt is not None and images is not None:
				__magic_name__       :    str     	=     {
				    '''pixel_values''': image_features.pixel_values,
				    '''conditional_pixel_values''': prompt_features.pixel_values,
				}
				return encoding
			elif text is not None and images is not None:
				__magic_name__       :    Any     	=     image_features.pixel_values
				return encoding
			elif text is not None:
				return encoding
			elif visual_prompt is not None:
				__magic_name__       :    Optional[int]     	=     {
				    '''conditional_pixel_values''': prompt_features.pixel_values,
				}
				return encoding
			else:
				return BatchEncoding(data=dict(**lowercase_			)  ,     tensor_type=lowercase_			)







		def    __lowerCAmelCase		(					self		:						Union[str, Any]  ,     *_A		:						Union[str, Any]  ,     **_A		:						Optional[Any]			)  -> List[Any]:
			return self.tokenizer.batch_decode(*lowercase_  ,     **lowercase_			)







		def    __lowerCAmelCase		(					self		:						List[Any]  ,     *_A		:						Dict  ,     **_A		:						Optional[Any]			)  -> Tuple:
			return self.tokenizer.decode(*lowercase_  ,     **lowercase_			)







		@property
		def    __lowerCAmelCase		(					self		:						Optional[Any]			)  -> Tuple:
			warnings.warn(
			    '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'  ,     lowercase_  ,     )
			return self.image_processor_class







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




"""simple docstring"""

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase__    :  str							    =	{
    '''configuration_x_clip''': [
        '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''XCLIPConfig''',
        '''XCLIPTextConfig''',
        '''XCLIPVisionConfig''',
    ],
    '''processing_x_clip''': ['''XCLIPProcessor'''],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowercase__    :  Tuple							    =	[
         '''XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''XCLIPModel''',
         '''XCLIPPreTrainedModel''',
         '''XCLIPTextModel''',
         '''XCLIPVisionModel''',
     ]

if TYPE_CHECKING:
     from .configuration_x_clip import (
         XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
         XCLIPConfig,
         XCLIPTextConfig,
         XCLIPVisionConfig,
     )
     from .processing_x_clip import XCLIPProcessor

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_x_clip import (
              XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
              XCLIPModel,
              XCLIPPreTrainedModel,
              XCLIPTextModel,
              XCLIPVisionModel,
          )

else:
     import sys

     lowercase__    :  Tuple							    =	_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





