






"""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 					_UpperCAmelCase       ( _A							):
					SCREAMING_SNAKE_CASE_		:				List[Any]							    =   ["image_processor", "tokenizer"]
					SCREAMING_SNAKE_CASE_		:				Union[str, Any]							    =   "BlipImageProcessor"
					SCREAMING_SNAKE_CASE_		:				int							    =   ("BertTokenizer", "BertTokenizerFast")




					def __init__(				self     :						int    ,						A     :						Optional[int]    ,						A     :						Union[str, Any]   )  ->  Tuple:
							lowercase_ : int							       =   False
							super().__init__(A    ,						A   )
							lowercase_ : str							       =   self.image_processor




					def __call__(				self     :						List[str]    ,						A     :						ImageInput = None    ,						A     :						Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None    ,						A     :						bool = True    ,						A     :						Union[bool, str, PaddingStrategy] = False    ,						A     :						Union[bool, str, TruncationStrategy] = None    ,						A     :						Optional[int] = None    ,						A     :						int = 0    ,						A     :						Optional[int] = None    ,						A     :						Optional[bool] = None    ,						A     :						bool = False    ,						A     :						bool = False    ,						A     :						bool = False    ,						A     :						bool = False    ,						A     :						bool = False    ,						A     :						bool = True    ,						A     :						Optional[Union[str, TensorType]] = None    ,						**A     :						Dict    ,						)  ->  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:
									lowercase_ : Optional[Any]							       =   self.tokenizer
									lowercase_ : Tuple							       =   self.tokenizer(
									    text=A    ,						add_special_tokens=A    ,						padding=A    ,						truncation=A    ,						max_length=A    ,						stride=A    ,						pad_to_multiple_of=A    ,						return_attention_mask=A    ,						return_overflowing_tokens=A    ,						return_special_tokens_mask=A    ,						return_offsets_mapping=A    ,						return_token_type_ids=A    ,						return_length=A    ,						verbose=A    ,						return_tensors=A    ,						**A    ,						)
									return text_encoding

							# add pixel_values
							lowercase_ : List[str]							       =   self.image_processor(A    ,						return_tensors=A   )

							if text is not None:
									lowercase_ : Optional[int]							       =   self.tokenizer(
									    text=A    ,						add_special_tokens=A    ,						padding=A    ,						truncation=A    ,						max_length=A    ,						stride=A    ,						pad_to_multiple_of=A    ,						return_attention_mask=A    ,						return_overflowing_tokens=A    ,						return_special_tokens_mask=A    ,						return_offsets_mapping=A    ,						return_token_type_ids=A    ,						return_length=A    ,						verbose=A    ,						return_tensors=A    ,						**A    ,						)
							else:
									lowercase_ : str							       =   None

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

							return encoding_image_processor




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




					def   A  (				self     :						int    ,						*A     :						Optional[int]    ,						**A     :						Any   )  ->  int:
							return self.tokenizer.decode(*A    ,						**A   )






					@property
					def   A  (				self     :						Optional[Any]   )  ->  Any:
							lowercase_ : Optional[Any]							       =   self.tokenizer.model_input_names
							lowercase_ : List[str]							       =   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_tokenizers_available,
    is_torch_available,
)


__A		:       Union[str, Any]  				=		{}

try:
						if not is_sentencepiece_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:       Dict  				=		['''NllbTokenizer''']

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:       Dict  				=		['''NllbTokenizerFast''']


if TYPE_CHECKING:
						try:
												if not is_sentencepiece_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_nllb import NllbTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_nllb_fast import NllbTokenizerFast

else:
						import sys

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



