






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__	):

				"""simple docstring"""




				lowercase__											=       ["""image_processor""", """tokenizer"""]
				lowercase__											=       """BlipImageProcessor"""
				lowercase__											=       ("""BertTokenizer""", """BertTokenizerFast""")




				def __init__(     self						:    Dict,  lowerCamelCase						:    Dict,  lowerCamelCase						:    str  ):

								'''simple docstring'''
								lowercase__    =			False
								super().__init__(lowerCamelCase,  lowerCamelCase  )
								lowercase__    =			self.image_processor




				def __call__(     self						:    int,  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						:    Any,  ):

								'''simple docstring'''
								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__    =			self.tokenizer
												lowercase__    =			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
								lowercase__    =			self.image_processor(lowerCamelCase,  return_tensors=lowerCamelCase  )

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

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

								return encoding_image_processor




				def 				lowercase__   (     self						:    Tuple,  *lowerCamelCase						:    Union[str, Any],  **lowerCamelCase						:    Optional[int]  ):

								'''simple docstring'''
								return self.tokenizer.batch_decode(*lowerCamelCase,  **lowerCamelCase  )




				def 				lowercase__   (     self						:    List[str],  *lowerCamelCase						:    int,  **lowerCamelCase						:    List[str]  ):

								'''simple docstring'''
								return self.tokenizer.decode(*lowerCamelCase,  **lowerCamelCase  )




				@property
				def 				lowercase__   (     self						:    List[str]  ):

								'''simple docstring'''
								lowercase__    =			self.tokenizer.model_input_names
								lowercase__    =			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					(       A__	):

				"""simple docstring"""




				def __init__(     self						:    Dict,  lowerCamelCase						:    pyspark.sql.DataFrame,  lowerCamelCase						:    Optional[NamedSplit] = None,  lowerCamelCase						:    Optional[Features] = None,  lowerCamelCase						:    bool = True,  lowerCamelCase						:    str = None,  lowerCamelCase						:    bool = False,  lowerCamelCase						:    str = None,  lowerCamelCase						:    bool = True,  lowerCamelCase						:    str = "arrow",  **lowerCamelCase						:    str,  ):

								'''simple docstring'''
								super().__init__(
								    split=lowerCamelCase,  features=lowerCamelCase,  cache_dir=lowerCamelCase,  keep_in_memory=lowerCamelCase,  streaming=lowerCamelCase,  **lowerCamelCase,  )
								lowercase__    =			load_from_cache_file
								lowercase__    =			file_format
								lowercase__    =			Spark(
								    df=lowerCamelCase,  features=lowerCamelCase,  cache_dir=lowerCamelCase,  working_dir=lowerCamelCase,  **lowerCamelCase,  )




				def 				lowercase__   (     self						:    List[Any]  ):

								'''simple docstring'''
								if self.streaming:
												return self.builder.as_streaming_dataset(split=self.split  )
								lowercase__    =			None if self._load_from_cache_file else DownloadMode.FORCE_REDOWNLOAD
								self.builder.download_and_prepare(
								    download_mode=lowerCamelCase,  file_format=self._file_format,  )
								return self.builder.as_dataset(split=self.split  )




