


'''simple docstring'''





import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding




class 				UpperCAmelCase			(			_snake_case						):
 UpperCAmelCase				=					["image_processor", "tokenizer"]
 UpperCAmelCase				=					"CLIPImageProcessor"
 UpperCAmelCase				=					("XLMRobertaTokenizer", "XLMRobertaTokenizerFast")


 def __init__(      self							:	List[Any]			,       __lowerCamelCase							:	int=None			,       __lowerCamelCase							:	Any=None			,       **__lowerCamelCase							:	Optional[int] ):
    UpperCAmelCase__	:Dict      =      None
    if "feature_extractor" in kwargs:
       warnings.warn(
           '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
           ''' instead.'''			,       __lowerCamelCase			,       )
       UpperCAmelCase__	:Optional[Any]      =      kwargs.pop('''feature_extractor''' )

    UpperCAmelCase__	:int      =      image_processor if image_processor is not None else feature_extractor
    if image_processor is None:
       raise ValueError('''You need to specify an `image_processor`.''' )
    if tokenizer is None:
       raise ValueError('''You need to specify a `tokenizer`.''' )

    super().__init__(__lowerCamelCase			,       __lowerCamelCase )


 def __call__(      self							:	Any			,       __lowerCamelCase							:	Optional[Any]=None			,       __lowerCamelCase							:	List[Any]=None			,       __lowerCamelCase							:	str=None			,       **__lowerCamelCase							:	Optional[Any] ):

    if text is None and images is None:
       raise ValueError('''You have to specify either text or images. Both cannot be none.''' )

    if text is not None:
       UpperCAmelCase__	:List[Any]      =      self.tokenizer(__lowerCamelCase			,       return_tensors=__lowerCamelCase			,       **__lowerCamelCase )

    if images is not None:
       UpperCAmelCase__	:Any      =      self.image_processor(__lowerCamelCase			,       return_tensors=__lowerCamelCase			,       **__lowerCamelCase )

    if text is not None and images is not None:
       UpperCAmelCase__	:Optional[int]      =      image_features.pixel_values
       return encoding
    elif text is not None:
       return encoding
    else:
       return BatchEncoding(data=dict(**__lowerCamelCase )			,       tensor_type=__lowerCamelCase )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Optional[Any]			,       *__lowerCamelCase							:	List[Any]			,       **__lowerCamelCase							:	Any ):
    return self.tokenizer.batch_decode(*__lowerCamelCase			,       **__lowerCamelCase )


 def        __SCREAMING_SNAKE_CASE					(      self							:	Union[str, Any]			,       *__lowerCamelCase							:	List[str]			,       **__lowerCamelCase							:	str ):
    return self.tokenizer.decode(*__lowerCamelCase			,       **__lowerCamelCase )





 @property
 def        __SCREAMING_SNAKE_CASE					(      self							:	str ):
    UpperCAmelCase__	:Dict      =      self.tokenizer.model_input_names
    UpperCAmelCase__	:Dict      =      self.image_processor.model_input_names
    return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names ) )







'''simple docstring'''





from .glue import GlueDataset, GlueDataTrainingArguments
from .language_modeling import (
    LineByLineTextDataset,
    LineByLineWithRefDataset,
    LineByLineWithSOPTextDataset,
    TextDataset,
    TextDatasetForNextSentencePrediction,
)
from .squad import SquadDataset, SquadDataTrainingArguments



