'''simple docstring'''

from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType







class 				_lowercase     (				UpperCAmelCase__			):


 '''simple docstring'''






 _SCREAMING_SNAKE_CASE     :       str      	=					["""image_processor""", """tokenizer"""]
 _SCREAMING_SNAKE_CASE     :       Optional[Any]      	=					"""BlipImageProcessor"""
 _SCREAMING_SNAKE_CASE     :       str      	=					"""AutoTokenizer"""
 def __init__(      self   :	Any      ,       SCREAMING_SNAKE_CASE__   :	Optional[int]      ,       SCREAMING_SNAKE_CASE__   :	List[Any]							)  ->    Optional[int]:
  __lowerCAmelCase											=						False
  super().__init__(snake_case_      ,       snake_case_							)
  __lowerCAmelCase											=						self.image_processor
 def __call__(      self   :	str      ,       SCREAMING_SNAKE_CASE__   :	Optional[Any] = None      ,       SCREAMING_SNAKE_CASE__   :	List[str] = None      ,       SCREAMING_SNAKE_CASE__   :	List[str] = True      ,       SCREAMING_SNAKE_CASE__   :	str = False      ,       SCREAMING_SNAKE_CASE__   :	Optional[int] = None      ,       SCREAMING_SNAKE_CASE__   :	List[str] = None      ,       SCREAMING_SNAKE_CASE__   :	Any = 0      ,       SCREAMING_SNAKE_CASE__   :	Tuple = None      ,       SCREAMING_SNAKE_CASE__   :	Optional[Any] = None      ,       SCREAMING_SNAKE_CASE__   :	str = False      ,       SCREAMING_SNAKE_CASE__   :	Optional[int] = False      ,       SCREAMING_SNAKE_CASE__   :	Optional[Any] = False      ,       SCREAMING_SNAKE_CASE__   :	List[Any] = False      ,       SCREAMING_SNAKE_CASE__   :	Any = False      ,       SCREAMING_SNAKE_CASE__   :	str = True      ,       SCREAMING_SNAKE_CASE__   :	Union[str, Any] = None      ,       **SCREAMING_SNAKE_CASE__   :	Union[str, Any]      ,       )  ->    Union[str, Any]:

  if images is None and text is None:
   raise ValueError("""You have to specify either images or text."""							)

  # Get only text
  if images is None:
   __lowerCAmelCase											=						self.tokenizer
   __lowerCAmelCase											=						self.tokenizer(
       text=snake_case_      ,       add_special_tokens=snake_case_      ,       padding=snake_case_      ,       truncation=snake_case_      ,       max_length=snake_case_      ,       stride=snake_case_      ,       pad_to_multiple_of=snake_case_      ,       return_attention_mask=snake_case_      ,       return_overflowing_tokens=snake_case_      ,       return_special_tokens_mask=snake_case_      ,       return_offsets_mapping=snake_case_      ,       return_token_type_ids=snake_case_      ,       return_length=snake_case_      ,       verbose=snake_case_      ,       return_tensors=snake_case_      ,       **snake_case_      ,       )
   return text_encoding

  # add pixel_values
  __lowerCAmelCase											=						self.image_processor(snake_case_      ,       return_tensors=snake_case_							)

  if text is not None:
   __lowerCAmelCase											=						self.tokenizer(
       text=snake_case_      ,       add_special_tokens=snake_case_      ,       padding=snake_case_      ,       truncation=snake_case_      ,       max_length=snake_case_      ,       stride=snake_case_      ,       pad_to_multiple_of=snake_case_      ,       return_attention_mask=snake_case_      ,       return_overflowing_tokens=snake_case_      ,       return_special_tokens_mask=snake_case_      ,       return_offsets_mapping=snake_case_      ,       return_token_type_ids=snake_case_      ,       return_length=snake_case_      ,       verbose=snake_case_      ,       return_tensors=snake_case_      ,       **snake_case_      ,       )
  else:
   __lowerCAmelCase											=						None

  if text_encoding is not None:
   encoding_image_processor.update(snake_case_							)

  return encoding_image_processor
 def a					(      self   :	Any      ,       *SCREAMING_SNAKE_CASE__   :	Tuple      ,       **SCREAMING_SNAKE_CASE__   :	int							)  ->    Tuple:
  return self.tokenizer.batch_decode(*snake_case_      ,       **snake_case_							)
 def a					(      self   :	Optional[int]      ,       *SCREAMING_SNAKE_CASE__   :	Optional[int]      ,       **SCREAMING_SNAKE_CASE__   :	Dict							)  ->    Tuple:
  return self.tokenizer.decode(*snake_case_      ,       **snake_case_							)





 @property
 # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
 def a					(      self   :	Any							)  ->    List[Any]:
  __lowerCAmelCase											=						self.tokenizer.model_input_names
  __lowerCAmelCase											=						self.image_processor.model_input_names
  return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)













"""simple docstring"""




from typing import TYPE_CHECKING

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


lowerCamelCase_     :						List[str]						=					{'configuration_xlnet': ['XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLNetConfig']}

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

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

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowerCamelCase_     :						int						=					[
       '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:
   lowerCamelCase_     :						Union[str, Any]						=					[
       '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

   lowerCamelCase_     :						List[Any]						=					_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)