




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			( __UpperCAmelCase  ):





				'''simple docstring'''



				__a							: int										=["""image_processor""", """tokenizer"""]
				__a							: Any										="""BlipImageProcessor"""
				__a							: Union[str, Any]										="""AutoTokenizer"""



				def __init__( self       , UpperCAmelCase_       , UpperCAmelCase_						):
											lowerCAmelCase   =		False
											super().__init__(UpperCAmelCase_       , UpperCAmelCase_						)
											lowerCAmelCase   =		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_       , ):
											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=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
											lowerCAmelCase   =		self.image_processor(UpperCAmelCase_       , return_tensors=UpperCAmelCase_						)

											if text is not None:
																		lowerCAmelCase   =		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:
																		lowerCAmelCase   =		None

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

											return encoding_image_processor



				def       __snake_case		( self       , *UpperCAmelCase_       , **UpperCAmelCase_						):
											return self.tokenizer.batch_decode(*UpperCAmelCase_       , **UpperCAmelCase_						)



				def       __snake_case		( self       , *UpperCAmelCase_       , **UpperCAmelCase_						):
											return self.tokenizer.decode(*UpperCAmelCase_       , **UpperCAmelCase_						)






				@property
				# Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
				def       __snake_case		( self						):
											lowerCAmelCase   =		self.tokenizer.model_input_names
											lowerCAmelCase   =		self.image_processor.model_input_names
											return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names						)						)









from typing import Optional

import pyspark

from .. import Features, NamedSplit
from ..download import DownloadMode
from ..packaged_modules.spark.spark import Spark
from .abc import AbstractDatasetReader


class 							__UpperCamelCase			( __UpperCAmelCase  ):





				'''simple docstring'''



				def __init__( self       , UpperCAmelCase_       , UpperCAmelCase_ = None       , UpperCAmelCase_ = None       , UpperCAmelCase_ = True       , UpperCAmelCase_ = None       , UpperCAmelCase_ = False       , UpperCAmelCase_ = None       , UpperCAmelCase_ = True       , UpperCAmelCase_ = "arrow"       , **UpperCAmelCase_       , ):
											super().__init__(
											    split=UpperCAmelCase_       , features=UpperCAmelCase_       , cache_dir=UpperCAmelCase_       , keep_in_memory=UpperCAmelCase_       , streaming=UpperCAmelCase_       , **UpperCAmelCase_       , )
											lowerCAmelCase   =		load_from_cache_file
											lowerCAmelCase   =		file_format
											lowerCAmelCase   =		Spark(
											    df=UpperCAmelCase_       , features=UpperCAmelCase_       , cache_dir=UpperCAmelCase_       , working_dir=UpperCAmelCase_       , **UpperCAmelCase_       , )






				def       __snake_case		( self						):
											if self.streaming:
																		return self.builder.as_streaming_dataset(split=self.split						)
											lowerCAmelCase   =		None if self._load_from_cache_file else DownloadMode.FORCE_REDOWNLOAD
											self.builder.download_and_prepare(
											    download_mode=UpperCAmelCase_       , file_format=self._file_format       , )
											return self.builder.as_dataset(split=self.split						)



