import warnings

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




class  __magic_name__  (		__a    ):





   """simple docstring"""




   lowerCAmelCase      :    int  			=   ['''image_processor''', '''tokenizer''']
   lowerCAmelCase      :    str  			=   '''ChineseCLIPImageProcessor'''
   lowerCAmelCase      :    Optional[int]  			=   ('''BertTokenizer''', '''BertTokenizerFast''')



   def __init__(	self					:  List[Any]		,  _lowercase					:  Any=None		,  _lowercase					:  Any=None		,  **_lowercase					:  Tuple							):



    """simple docstring"""



    _UpperCamelCase:     Optional[int]							= 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		,  )
     _UpperCamelCase:     Union[str, Any]							= kwargs.pop('''feature_extractor'''							)

    _UpperCamelCase:     List[str]							= 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							)
    _UpperCamelCase:     Dict							= self.image_processor



   def __call__(	self					:  List[str]		,  _lowercase					:  Optional[Any]=None		,  _lowercase					:  Union[str, Any]=None		,  _lowercase					:  Any=None		,  **_lowercase					:  List[Any]							):



    """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:     Optional[int]							= self.tokenizer(_lowercase		,  return_tensors=_lowercase		,  **_lowercase							)

    if images is not None:
     _UpperCamelCase:     Any							= self.image_processor(_lowercase		,  return_tensors=_lowercase		,  **_lowercase							)

    if text is not None and images is not None:
     _UpperCamelCase:     Optional[int]							= image_features.pixel_values
     return encoding
    elif text is not None:
     return encoding
    else:
     return BatchEncoding(data=dict(**_lowercase							)		,  tensor_type=_lowercase							)



   def   lowerCAmelCase						(	self					:  Union[str, Any]		,  *_lowercase					:  Union[str, Any]		,  **_lowercase					:  Optional[Any]							):



    """simple docstring"""



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



   def   lowerCAmelCase						(	self					:  Optional[int]		,  *_lowercase					:  Dict		,  **_lowercase					:  Optional[Any]							):



    """simple docstring"""



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



   @property
   def   lowerCAmelCase						(	self					:  Dict							):



    """simple docstring"""



    _UpperCamelCase:     int							= self.tokenizer.model_input_names
    _UpperCamelCase:     int							= self.image_processor.model_input_names
    return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)



   @property
   def   lowerCAmelCase						(	self					:  str							):



    """simple docstring"""



    warnings.warn(
        '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''		,  _lowercase		,  )
    return self.image_processor_class
from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase_			    =							{'''configuration_xlnet''': ['''XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLNetConfig''']}

try:
  if not is_sentencepiece_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase_			    =							['''XLNetTokenizer''']

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase_			    =							['''XLNetTokenizerFast''']

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase_			    =							[
      '''XLNET_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''XLNetForMultipleChoice''',
      '''XLNetForQuestionAnswering''',
      '''XLNetForQuestionAnsweringSimple''',
      '''XLNetForSequenceClassification''',
      '''XLNetForTokenClassification''',
      '''XLNetLMHeadModel''',
      '''XLNetModel''',
      '''XLNetPreTrainedModel''',
      '''load_tf_weights_in_xlnet''',
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase_			    =							[
      '''TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''TFXLNetForMultipleChoice''',
      '''TFXLNetForQuestionAnsweringSimple''',
      '''TFXLNetForSequenceClassification''',
      '''TFXLNetForTokenClassification''',
      '''TFXLNetLMHeadModel''',
      '''TFXLNetMainLayer''',
      '''TFXLNetModel''',
      '''TFXLNetPreTrainedModel''',
  ]


if TYPE_CHECKING:
  from .configuration_xlnet import XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLNetConfig

  try:
    if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_xlnet import XLNetTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_xlnet_fast import XLNetTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_xlnet import (
        XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
        XLNetForMultipleChoice,
        XLNetForQuestionAnswering,
        XLNetForQuestionAnsweringSimple,
        XLNetForSequenceClassification,
        XLNetForTokenClassification,
        XLNetLMHeadModel,
        XLNetModel,
        XLNetPreTrainedModel,
        load_tf_weights_in_xlnet,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_xlnet import (
        TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFXLNetForMultipleChoice,
        TFXLNetForQuestionAnsweringSimple,
        TFXLNetForSequenceClassification,
        TFXLNetForTokenClassification,
        TFXLNetLMHeadModel,
        TFXLNetMainLayer,
        TFXLNetModel,
        TFXLNetPreTrainedModel,
    )

else:
  import sys

  UpperCAmelCase_			    =							_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)