


import warnings

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


class 	A_ (	__UpperCamelCase   ):




      '''simple docstring'''


      __snake_case 	=       ["""image_processor""", """tokenizer"""]
      __snake_case 	=       """CLIPImageProcessor"""
      __snake_case 	=       ("""XLMRobertaTokenizer""", """XLMRobertaTokenizerFast""")




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

       __lowerCamelCase		:							str		 =						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__(a						,				a    )




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

       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:
        __lowerCamelCase		:							Optional[int]		 =						self.tokenizer(a						,				return_tensors=a						,				**a    )

       if images is not None:
        __lowerCamelCase		:							Union[str, Any]		 =						self.image_processor(a						,				return_tensors=a						,				**a    )

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




      def 					_snake_case     (    self:	List[Any]						,				*a:	int						,				**a:	Dict    ):
       return self.tokenizer.batch_decode(*a						,				**a    )




      def 					_snake_case     (    self:	Any						,				*a:	Dict						,				**a:	List[Any]    ):
       return self.tokenizer.decode(*a						,				**a    )




      @property
      def 					_snake_case     (    self:	Dict    ):
       __lowerCamelCase		:							Tuple		 =						self.tokenizer.model_input_names
       __lowerCamelCase		:							Optional[Any]		 =						self.image_processor.model_input_names
       return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names    )    )





import datasets


lowercase_	   =     '\\n@InProceedings{conneau2018xnli,\n  author = "Conneau, Alexis\n                 and Rinott, Ruty\n                 and Lample, Guillaume\n                 and Williams, Adina\n                 and Bowman, Samuel R.\n                 and Schwenk, Holger\n                 and Stoyanov, Veselin",\n  title = "XNLI: Evaluating Cross-lingual Sentence Representations",\n  booktitle = "Proceedings of the 2018 Conference on Empirical Methods\n               in Natural Language Processing",\n  year = "2018",\n  publisher = "Association for Computational Linguistics",\n  location = "Brussels, Belgium",\n}\n'

lowercase_	   =     '\\nXNLI is a subset of a few thousand examples from MNLI which has been translated\ninto a 14 different languages (some low-ish resource). As with MNLI, the goal is\nto predict textual entailment (does sentence A imply/contradict/neither sentence\nB) and is a classification task (given two sentences, predict one of three\nlabels).\n'

lowercase_	   =     '\nComputes XNLI score which is just simple accuracy.\nArgs:\n    predictions: Predicted labels.\n    references: Ground truth labels.\nReturns:\n    \'accuracy\': accuracy\nExamples:\n\n    >>> predictions = [0, 1]\n    >>> references = [0, 1]\n    >>> xnli_metric = datasets.load_metric("xnli")\n    >>> results = xnli_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {\'accuracy\': 1.0}\n'
def 				UpperCamelCase__					(  SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__						):
 return (preds == labels).mean()



@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION ,				_KWARGS_DESCRIPTION   )
class 	A_ (	datasets.Metric   ):




      '''simple docstring'''


      def 					_snake_case     (    self:	Union[str, Any]    ):
       return datasets.MetricInfo(
           description=_DESCRIPTION						,				citation=_CITATION						,				inputs_description=_KWARGS_DESCRIPTION						,				features=datasets.Features(
               {
                   'predictions': datasets.Value('int64' if self.config_name != 'sts-b' else 'float32'    ),
                   'references': datasets.Value('int64' if self.config_name != 'sts-b' else 'float32'    ),
               }    )						,				codebase_urls=[]						,				reference_urls=[]						,				format='numpy'						,				)




      def 					_snake_case     (    self:	int						,				a:	Optional[Any]						,				a:	Optional[Any]    ):
       return {"accuracy": simple_accuracy(a						,				a    )}

