




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 					snake_case__							(_UpperCamelCase     ):
				"""simple docstring"""



				SCREAMING_SNAKE_CASE_ :							str											=      ["""image_processor""", """tokenizer"""]
				SCREAMING_SNAKE_CASE_ :							int											=      """BlipImageProcessor"""
				SCREAMING_SNAKE_CASE_ :							Optional[int]											=      ("""BertTokenizer""", """BertTokenizerFast""")





				def __init__(   self       :  Dict      ,   __lowerCamelCase       :  Any      ,   __lowerCamelCase       :  Union[str, Any]							)      ->  Optional[int]:
							a					=    False
							super().__init__(__lowerCamelCase      ,   __lowerCamelCase							)
							a					=    self.image_processor





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

							# add pixel_values
							a					=    self.image_processor(__lowerCamelCase      ,   return_tensors=__lowerCamelCase							)

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

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

							return encoding_image_processor





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





				def 							__UpperCAmelCase							(   self       :  Optional[Any]      ,   *__lowerCamelCase       :  int      ,   **__lowerCamelCase       :  str							)      ->  List[Any]:
							return self.tokenizer.decode(*__lowerCamelCase      ,   **__lowerCamelCase							)





				@property
				def 							__UpperCAmelCase							(   self       :  Optional[Any]							)      ->  List[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							)							)












from typing import List, Optional, TypeVar

from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .info import DatasetInfo
from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interleave_iterable_datasets
from .splits import NamedSplit
from .utils import logging
from .utils.py_utils import Literal


__lowerCAmelCase	:       List[Any]     =	logging.get_logger(__name__)


__lowerCAmelCase	:       List[Any]     =	TypeVar('DatasetType', Dataset, IterableDataset)




def     __magic_name__       (				A	:      List[DatasetType],						A	:      Optional[List[float]] = None,						A	:      Optional[int] = None,						A	:      Optional[DatasetInfo] = None,						A	:      Optional[NamedSplit] = None,						A	:      Literal["first_exhausted", "all_exhausted"] = "first_exhausted",						):






			'''simple docstring'''







			from .arrow_dataset import Dataset
			from .iterable_dataset import IterableDataset

			if not datasets:
						raise ValueError("Unable to interleave an empty list of datasets."     )
			for i, dataset in enumerate(A     ):
						if not isinstance(A,						(Dataset, IterableDataset)     ):
									if isinstance(A,						(DatasetDict, IterableDatasetDict)     ):
												if not dataset:
															raise ValueError(
															    F"""Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} """
															    "is an empty dataset dictionary."     )
												raise ValueError(
												    F"""Dataset at position {i} has at least one split: {list(A     )}\n"""
												    F"""Please pick one to interleave with the other datasets, for example: dataset['{next(iter(A     )     )}']"""     )
									raise ValueError(
									    F"""Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(A     ).__name__}."""     )
						if i == 0:
									a					,	a					=    (
									    (Dataset, IterableDataset) if isinstance(A,						A     ) else (IterableDataset, Dataset)
									)
						elif not isinstance(A,						A     ):
									raise ValueError(
									    F"""Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects."""     )
			if stopping_strategy not in ["first_exhausted", "all_exhausted"]:
						raise ValueError(F"""{stopping_strategy} is not supported. Please enter a valid stopping_strategy."""     )
			if dataset_type is Dataset:
						return _interleave_map_style_datasets(
						    A,						A,						A,						info=A,						split=A,						stopping_strategy=A     )
			else:
						return _interleave_iterable_datasets(
						    A,						A,						A,						info=A,						split=A,						stopping_strategy=A     )






def     __magic_name__       (				A	:      List[DatasetType],						A	:      Optional[DatasetInfo] = None,						A	:      Optional[NamedSplit] = None,						A	:      int = 0,						):






			'''simple docstring'''







			if not dsets:
						raise ValueError("Unable to concatenate an empty list of datasets."     )
			for i, dataset in enumerate(A     ):
						if not isinstance(A,						(Dataset, IterableDataset)     ):
									if isinstance(A,						(DatasetDict, IterableDatasetDict)     ):
												if not dataset:
															raise ValueError(
															    F"""Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} """
															    "is an empty dataset dictionary."     )
												raise ValueError(
												    F"""Dataset at position {i} has at least one split: {list(A     )}\n"""
												    F"""Please pick one to interleave with the other datasets, for example: dataset['{next(iter(A     )     )}']"""     )
									raise ValueError(
									    F"""Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(A     ).__name__}."""     )
						if i == 0:
									a					,	a					=    (
									    (Dataset, IterableDataset) if isinstance(A,						A     ) else (IterableDataset, Dataset)
									)
						elif not isinstance(A,						A     ):
									raise ValueError(
									    F"""Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects."""     )
			if dataset_type is Dataset:
						return _concatenate_map_style_datasets(A,						info=A,						split=A,						axis=A     )
			else:
						return _concatenate_iterable_datasets(A,						info=A,						split=A,						axis=A     )






