


"""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     __lowerCamelCase  (					a__				):

     '''simple docstring'''
     A_       :	Optional[int]    =		['image_processor', 'tokenizer']
     A_       :	List[Any]    =		'BlipImageProcessor'
     A_       :	Any    =		'AutoTokenizer'


     def __init__(      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase							)       ->							Optional[int]:
          _a    	=				False
          super().__init__(__UpperCAmelCase    ,				__UpperCAmelCase							)
          _a    	=				self.image_processor


     def __call__(      self    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = True    ,				__UpperCAmelCase = False    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = 0    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = None    ,				__UpperCAmelCase = False    ,				__UpperCAmelCase = False    ,				__UpperCAmelCase = False    ,				__UpperCAmelCase = False    ,				__UpperCAmelCase = False    ,				__UpperCAmelCase = True    ,				__UpperCAmelCase = None    ,				**__UpperCAmelCase    ,				)       ->							BatchEncoding:
          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:
               _a    	=				self.tokenizer
               _a    	=				self.tokenizer(
                   text=__UpperCAmelCase    ,				add_special_tokens=__UpperCAmelCase    ,				padding=__UpperCAmelCase    ,				truncation=__UpperCAmelCase    ,				max_length=__UpperCAmelCase    ,				stride=__UpperCAmelCase    ,				pad_to_multiple_of=__UpperCAmelCase    ,				return_attention_mask=__UpperCAmelCase    ,				return_overflowing_tokens=__UpperCAmelCase    ,				return_special_tokens_mask=__UpperCAmelCase    ,				return_offsets_mapping=__UpperCAmelCase    ,				return_token_type_ids=__UpperCAmelCase    ,				return_length=__UpperCAmelCase    ,				verbose=__UpperCAmelCase    ,				return_tensors=__UpperCAmelCase    ,				**__UpperCAmelCase    ,				)
               return text_encoding

          # add pixel_values
          _a    	=				self.image_processor(__UpperCAmelCase    ,				return_tensors=__UpperCAmelCase							)

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

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

          return encoding_image_processor


     def 							_UpperCAmelCase      (      self    ,				*__UpperCAmelCase    ,				**__UpperCAmelCase							)       ->							Dict:
          return self.tokenizer.batch_decode(*__UpperCAmelCase    ,				**__UpperCAmelCase							)


     def 							_UpperCAmelCase      (      self    ,				*__UpperCAmelCase    ,				**__UpperCAmelCase							)       ->							Dict:
          return self.tokenizer.decode(*__UpperCAmelCase    ,				**__UpperCAmelCase							)





     @property
     # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
     def 							_UpperCAmelCase      (      self							)       ->							Union[str, Any]:
          _a    	=				self.tokenizer.model_input_names
          _a    	=				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_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__snake_case		=       {
    '''configuration_lxmert''': ['''LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LxmertConfig'''],
    '''tokenization_lxmert''': ['''LxmertTokenizer'''],
}

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

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __snake_case		=       [
       '''LxmertEncoder''',
       '''LxmertForPreTraining''',
       '''LxmertForQuestionAnswering''',
       '''LxmertModel''',
       '''LxmertPreTrainedModel''',
       '''LxmertVisualFeatureEncoder''',
       '''LxmertXLayer''',
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __snake_case		=       [
       '''TF_LXMERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''TFLxmertForPreTraining''',
       '''TFLxmertMainLayer''',
       '''TFLxmertModel''',
       '''TFLxmertPreTrainedModel''',
       '''TFLxmertVisualFeatureEncoder''',
   ]


if TYPE_CHECKING:
   from .configuration_lxmert import LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP, LxmertConfig
   from .tokenization_lxmert import LxmertTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_lxmert_fast import LxmertTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_lxmert import (
          LxmertEncoder,
          LxmertForPreTraining,
          LxmertForQuestionAnswering,
          LxmertModel,
          LxmertPreTrainedModel,
          LxmertVisualFeatureEncoder,
          LxmertXLayer,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_lxmert import (
          TF_LXMERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFLxmertForPreTraining,
          TFLxmertMainLayer,
          TFLxmertModel,
          TFLxmertPreTrainedModel,
          TFLxmertVisualFeatureEncoder,
      )

else:
   import sys

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