


from typing import List

from packaging import version
from sklearn.metrics import fa_score

import datasets
from datasets.config import PY_VERSION


if PY_VERSION < version.parse('3.8'):
 import importlib_metadata
else:
 import importlib.metadata as importlib_metadata


# TODO(Patrick/Anton)
lowerCamelCase						 =	'\\n'

lowerCamelCase						 =	'\\n    XTREME-S is a benchmark to evaluate universal cross-lingual speech representations in many languages.\n    XTREME-S covers four task families: speech recognition, classification, speech-to-text translation and retrieval.\n'

lowerCamelCase						 =	'\nCompute XTREME-S evaluation metric associated to each XTREME-S dataset.\nArgs:\n    predictions: list of predictions to score.\n        Each translation should be tokenized into a list of tokens.\n    references: list of lists of references for each translation.\n        Each reference should be tokenized into a list of tokens.\n    bleu_kwargs: optional dict of keywords to be passed when computing \'bleu\'.\n        Keywords include Dict can be one of \'smooth_method\', \'smooth_value\', \'force\', \'lowercase\',\n        \'tokenize\', \'use_effective_order\'.\n    wer_kwargs: optional dict of keywords to be passed when computing \'wer\' and \'cer\'.\n        Keywords include \'concatenate_texts\'.\nReturns: depending on the XTREME-S task, one or several of:\n    "accuracy": Accuracy - for \'fleurs-lang_id\', \'minds14\'\n    "f1": F1 score - for \'minds14\'\n    "wer": Word error rate - for \'mls\', \'fleurs-asr\', \'voxpopuli\', \'babel\'\n    "cer": Character error rate - for \'mls\', \'fleurs-asr\', \'voxpopuli\', \'babel\'\n    "bleu": BLEU score according to the `sacrebleu` metric - for \'covost2\'\nExamples:\n\n    >>> xtreme_s_metric = datasets.load_metric(\'xtreme_s\', \'mls\')  # \'mls\', \'voxpopuli\', \'fleurs-asr\' or \'babel\'\n    >>> references = ["it is sunny here", "paper and pen are essentials"]\n    >>> predictions = ["it\'s sunny", "paper pen are essential"]\n    >>> results = xtreme_s_metric.compute(predictions=predictions, references=references)\n    >>> print({k: round(v, 2) for k, v in results.items()})\n    {\'wer\': 0.56, \'cer\': 0.27}\n\n    >>> xtreme_s_metric = datasets.load_metric(\'xtreme_s\', \'covost2\')\n    >>> references = ["bonjour paris", "il est necessaire de faire du sport de temps en temp"]\n    >>> predictions = ["bonjour paris", "il est important de faire du sport souvent"]\n    >>> results = xtreme_s_metric.compute(predictions=predictions, references=references)\n    >>> print({k: round(v, 2) for k, v in results.items()})\n    {\'bleu\': 31.65}\n\n    >>> xtreme_s_metric = datasets.load_metric(\'xtreme_s\', \'fleurs-lang_id\')\n    >>> references = [0, 1, 0, 0, 1]\n    >>> predictions = [0, 1, 1, 0, 0]\n    >>> results = xtreme_s_metric.compute(predictions=predictions, references=references)\n    >>> print({k: round(v, 2) for k, v in results.items()})\n    {\'accuracy\': 0.6}\n\n    >>> xtreme_s_metric = datasets.load_metric(\'xtreme_s\', \'minds14\')\n    >>> references = [0, 1, 0, 0, 1]\n    >>> predictions = [0, 1, 1, 0, 0]\n    >>> results = xtreme_s_metric.compute(predictions=predictions, references=references)\n    >>> print({k: round(v, 2) for k, v in results.items()})\n    {\'f1\': 0.58, \'accuracy\': 0.6}\n'

lowerCamelCase						 =	['fleurs-asr', 'mls', 'voxpopuli', 'babel', 'covost2', 'fleurs-lang_id', 'minds14']
lowerCamelCase						 =	''

try:
 from jiwer import transforms as tr

 lowerCamelCase						 =	True
except ImportError:
 lowerCamelCase						 =	False

if _jiwer_available and version.parse(importlib_metadata.version('jiwer')) < version.parse('2.3.0'):




 class A  (       tr.AbstractTransform					):






       def __init__( self						:					Optional[Any]      ,       lowercase_						:					str = " "			) ->						Dict:
              """simple docstring"""




              _lowerCamelCase	:		List[str]          =sentence_delimiter






       def 	lowerCamelCase	( self						:					List[Any]      ,       lowercase_						:					str			) ->						List[str]:
              """simple docstring"""




              return list(lowercase_			)






       def 	lowerCamelCase	( self						:					Any      ,       lowercase_						:					List[str]			) ->						Dict:
              """simple docstring"""




              _lowerCamelCase	:		Tuple          =[]
              for sent_idx, sentence in enumerate(lowercase_			):
                     chars.extend(self.process_string(lowercase_			)			)
                     if self.sentence_delimiter is not None and self.sentence_delimiter != "" and sent_idx < len(lowercase_			) - 1:
                            chars.append(self.sentence_delimiter			)
              return chars




 lowerCamelCase						 =	tr.Compose(
     [tr.RemoveMultipleSpaces(), tr.Strip(), SentencesToListOfCharacters(SENTENCE_DELIMITER)]
 )
elif _jiwer_available:
 lowerCamelCase						 =	tr.Compose(
     [
         tr.RemoveMultipleSpaces(),
         tr.Strip(),
         tr.ReduceToSingleSentence(SENTENCE_DELIMITER),
         tr.ReduceToListOfListOfChars(),
     ]
 )
else:
 lowerCamelCase						 =	None




def      a_				(   SCREAMING_SNAKE_CASE__ :				Optional[Any]		,      SCREAMING_SNAKE_CASE__ :				Union[str, Any]					):
       '''simple docstring'''





       return float((preds == labels).mean()					)




def      a_				(   SCREAMING_SNAKE_CASE__ :				List[Any]		,      SCREAMING_SNAKE_CASE__ :				List[Any]					):
       '''simple docstring'''





       return {
           "f1": float(fa_score(y_true=SCREAMING_SNAKE_CASE__		,      y_pred=SCREAMING_SNAKE_CASE__		,      average='macro'					)					),
           "accuracy": simple_accuracy(SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__					),
       }




def      a_				(   SCREAMING_SNAKE_CASE__ :				List[Any]		,      SCREAMING_SNAKE_CASE__ :				List[str]		,      SCREAMING_SNAKE_CASE__ :				Any="exp"		,      SCREAMING_SNAKE_CASE__ :				int=None		,      SCREAMING_SNAKE_CASE__ :				List[Any]=False		,      SCREAMING_SNAKE_CASE__ :				Dict=False		,      SCREAMING_SNAKE_CASE__ :				List[str]=None		,      SCREAMING_SNAKE_CASE__ :				int=False		,      ):
       '''simple docstring'''





       _lowerCamelCase	:		Optional[Any]          =[[label] for label in labels]
       _lowerCamelCase	:		int          =list(SCREAMING_SNAKE_CASE__					)
       try:
              import sacrebleu as scb
       except ImportError:
              raise ValueError(
                  'sacrebleu has to be installed in order to apply the bleu metric for covost2.'
                  'You can install it via `pip install sacrebleu`.'					)

       if version.parse(scb.__version__					) < version.parse('1.4.12'					):
              raise ImportWarning(
                  'To use `sacrebleu`, the module `sacrebleu>=1.4.12` is required, and the current version of `sacrebleu` doesn\'t match this condition.\n'
                  'You can install it with `pip install "sacrebleu>=1.4.12"`.'					)

       _lowerCamelCase	:		Optional[int]          =len(labels[0]					)
       if any(len(SCREAMING_SNAKE_CASE__					) != references_per_prediction for refs in labels					):
              raise ValueError('Sacrebleu requires the same number of references for each prediction'					)
       _lowerCamelCase	:		Dict          =[[refs[i] for refs in labels] for i in range(SCREAMING_SNAKE_CASE__					)]
       _lowerCamelCase	:		Optional[Any]          =scb.corpus_bleu(
           SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__		,      smooth_method=SCREAMING_SNAKE_CASE__		,      smooth_value=SCREAMING_SNAKE_CASE__		,      force=SCREAMING_SNAKE_CASE__		,      lowercase=SCREAMING_SNAKE_CASE__		,      use_effective_order=SCREAMING_SNAKE_CASE__		,      **({'tokenize': tokenize} if tokenize else {})		,      )
       return {"bleu": output.score}




def      a_				(   SCREAMING_SNAKE_CASE__ :				List[str]		,      SCREAMING_SNAKE_CASE__ :				Union[str, Any]		,      SCREAMING_SNAKE_CASE__ :				str		,      SCREAMING_SNAKE_CASE__ :				Union[str, Any]					):
       '''simple docstring'''





       try:
              from jiwer import compute_measures
       except ImportError:
              raise ValueError(
                  F'''jiwer has to be installed in order to apply the wer metric for {config_name}.'''
                  'You can install it via `pip install jiwer`.'					)

       if concatenate_texts:
              _lowerCamelCase	:		Any          =compute_measures(SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__					)['wer']

              _lowerCamelCase	:		List[Any]          =compute_measures(SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__		,      truth_transform=SCREAMING_SNAKE_CASE__		,      hypothesis_transform=SCREAMING_SNAKE_CASE__					)['wer']
              return {"wer": wer, "cer": cer}
       else:

              def compute_score(SCREAMING_SNAKE_CASE__ :				List[str]		,      SCREAMING_SNAKE_CASE__ :				Optional[Any]		,      SCREAMING_SNAKE_CASE__ :				List[Any]="wer"					):
                     _lowerCamelCase	:		Optional[int]          =0
                     _lowerCamelCase	:		Dict          =0
                     for prediction, reference in zip(SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__					):
                            if score_type == "wer":
                                   _lowerCamelCase	:		Tuple          =compute_measures(SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__					)
                            elif score_type == "cer":
                                   _lowerCamelCase	:		Any          =compute_measures(
                                       SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__		,      truth_transform=SCREAMING_SNAKE_CASE__		,      hypothesis_transform=SCREAMING_SNAKE_CASE__					)
                            incorrect += measures["substitutions"] + measures["deletions"] + measures["insertions"]
                            total += measures["substitutions"] + measures["deletions"] + measures["hits"]
                     return incorrect / total

              return {"wer": compute_score(SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__		,      'wer'					), "cer": compute_score(SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__		,      'cer'					)}




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






      def 	lowerCamelCase	( self						:					str			) ->						Optional[Any]:
             """simple docstring"""




             if self.config_name not in _CONFIG_NAMES:
                    raise KeyError(F'''You should supply a configuration name selected in {_CONFIG_NAMES}'''			)

             _lowerCamelCase	:		Any          ='int64' if self.config_name in ['fleurs-lang_id', 'minds14'] else 'string'

             return datasets.MetricInfo(
                 description=_DESCRIPTION      ,       citation=_CITATION      ,       inputs_description=_KWARGS_DESCRIPTION      ,       features=datasets.Features(
                     {'predictions': datasets.Value(lowercase_			), 'references': datasets.Value(lowercase_			)}			)      ,       codebase_urls=[]      ,       reference_urls=[]      ,       format='numpy'      ,       )






      def 	lowerCamelCase	( self						:					Optional[Any]      ,       lowercase_						:					Optional[int]      ,       lowercase_						:					List[str]      ,       lowercase_						:					Optional[Any]=None      ,       lowercase_						:					List[Any]=None			) ->						Dict:
             """simple docstring"""




             _lowerCamelCase	:		Optional[Any]          =bleu_kwargs if bleu_kwargs is not None else {}
             _lowerCamelCase	:		Dict          =wer_kwargs if wer_kwargs is not None else {}

             if self.config_name == "fleurs-lang_id":
                    return {"accuracy": simple_accuracy(lowercase_      ,       lowercase_			)}
             elif self.config_name == "minds14":
                    return fa_and_simple_accuracy(lowercase_      ,       lowercase_			)
             elif self.config_name == "covost2":
                    _lowerCamelCase	:		List[str]          =bleu_kwargs.pop('smooth_method'      ,       'exp'			)
                    _lowerCamelCase	:		int          =bleu_kwargs.pop('smooth_value'      ,       lowercase_			)
                    _lowerCamelCase	:		int          =bleu_kwargs.pop('force'      ,       lowercase_			)
                    _lowerCamelCase	:		str          =bleu_kwargs.pop('lowercase'      ,       lowercase_			)
                    _lowerCamelCase	:		int          =bleu_kwargs.pop('tokenize'      ,       lowercase_			)
                    _lowerCamelCase	:		int          =bleu_kwargs.pop('use_effective_order'      ,       lowercase_			)
                    return bleu(
                        preds=lowercase_      ,       labels=lowercase_      ,       smooth_method=lowercase_      ,       smooth_value=lowercase_      ,       force=lowercase_      ,       lowercase=lowercase_      ,       tokenize=lowercase_      ,       use_effective_order=lowercase_      ,       )
             elif self.config_name in ["fleurs-asr", "mls", "voxpopuli", "babel"]:
                    _lowerCamelCase	:		Optional[Any]          =wer_kwargs.pop('concatenate_texts'      ,       lowercase_			)
                    return wer_and_cer(lowercase_      ,       lowercase_      ,       lowercase_      ,       self.config_name			)
             else:
                    raise KeyError(F'''You should supply a configuration name selected in {_CONFIG_NAMES}'''			)






import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin


if is_torch_available():
 import torch

if is_vision_available():
 from PIL import Image

 from transformers import CLIPImageProcessor




class A  (       unittest.TestCase					):






      def __init__( self						:					Union[str, Any]      ,       lowercase_						:					Any      ,       lowercase_						:					Optional[Any]=7      ,       lowercase_						:					Union[str, Any]=3      ,       lowercase_						:					Any=18      ,       lowercase_						:					Optional[int]=30      ,       lowercase_						:					int=400      ,       lowercase_						:					List[Any]=True      ,       lowercase_						:					List[str]=None      ,       lowercase_						:					Optional[Any]=True      ,       lowercase_						:					Tuple=None      ,       lowercase_						:					str=True      ,       lowercase_						:					Any=[0.48145466, 0.4578275, 0.40821073]      ,       lowercase_						:					Optional[int]=[0.26862954, 0.26130258, 0.27577711]      ,       lowercase_						:					Dict=True      ,       ) ->						str:
             """simple docstring"""




             _lowerCamelCase	:		List[str]          =size if size is not None else {'shortest_edge': 20}
             _lowerCamelCase	:		Optional[Any]          =crop_size if crop_size is not None else {'height': 18, 'width': 18}
             _lowerCamelCase	:		Any          =parent
             _lowerCamelCase	:		List[Any]          =batch_size
             _lowerCamelCase	:		Union[str, Any]          =num_channels
             _lowerCamelCase	:		str          =image_size
             _lowerCamelCase	:		str          =min_resolution
             _lowerCamelCase	:		Optional[int]          =max_resolution
             _lowerCamelCase	:		str          =do_resize
             _lowerCamelCase	:		Tuple          =size
             _lowerCamelCase	:		Any          =do_center_crop
             _lowerCamelCase	:		Any          =crop_size
             _lowerCamelCase	:		Optional[Any]          =do_normalize
             _lowerCamelCase	:		List[Any]          =image_mean
             _lowerCamelCase	:		int          =image_std
             _lowerCamelCase	:		Any          =do_convert_rgb






      def 	lowerCamelCase	( self						:					int			) ->						Tuple:
             """simple docstring"""




             return {
                 "do_resize": self.do_resize,
                 "size": self.size,
                 "do_center_crop": self.do_center_crop,
                 "crop_size": self.crop_size,
                 "do_normalize": self.do_normalize,
                 "image_mean": self.image_mean,
                 "image_std": self.image_std,
                 "do_convert_rgb": self.do_convert_rgb,
             }






      def 	lowerCamelCase	( self						:					List[str]      ,       lowercase_						:					Any=False      ,       lowercase_						:					str=False      ,       lowercase_						:					Union[str, Any]=False			) ->						Tuple:
             """simple docstring"""




             assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

             if equal_resolution:
                    _lowerCamelCase	:		int          =[]
                    for i in range(self.batch_size			):
                           image_inputs.append(
                               np.random.randint(
                                   255      ,       size=(self.num_channels, self.max_resolution, self.max_resolution)      ,       dtype=np.uinta			)			)
             else:
                    _lowerCamelCase	:		Dict          =[]
                    for i in range(self.batch_size			):
                           _lowerCamelCase     ,					_lowerCamelCase	:		str          =np.random.choice(np.arange(self.min_resolution      ,       self.max_resolution			)      ,       2			)
                           image_inputs.append(np.random.randint(255      ,       size=(self.num_channels, width, height)      ,       dtype=np.uinta			)			)

             if not numpify and not torchify:
                    # PIL expects the channel dimension as last dimension
                    _lowerCamelCase	:		Optional[int]          =[Image.fromarray(np.moveaxis(lowercase_      ,       0      ,       -1			)			) for x in image_inputs]

             if torchify:
                    _lowerCamelCase	:		Tuple          =[torch.from_numpy(lowercase_			) for x in image_inputs]

             return image_inputs




@require_torch
@require_vision
class A  (       UpperCamelCase_   ,							unittest.TestCase					):
      UpperCamelCase__							:  Tuple				=CLIPImageProcessor if is_vision_available() else None






      def 	lowerCamelCase	( self						:					Optional[Any]			) ->						Dict:
             """simple docstring"""




             _lowerCamelCase	:		Tuple          =CLIPImageProcessingTester(self			)






      @property
      def 	lowerCamelCase	( self						:					Tuple			) ->						Dict:
             """simple docstring"""




             return self.image_processor_tester.prepare_image_processor_dict()






      def 	lowerCamelCase	( self						:					int			) ->						str:
             """simple docstring"""




             _lowerCamelCase	:		Optional[int]          =self.image_processing_class(**self.image_processor_dict			)
             self.assertTrue(hasattr(lowercase_      ,       'do_resize'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'size'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'do_center_crop'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'center_crop'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'do_normalize'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'image_mean'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'image_std'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'do_convert_rgb'			)			)






      def 	lowerCamelCase	( self						:					Any			) ->						Tuple:
             """simple docstring"""




             _lowerCamelCase	:		int          =self.image_processing_class.from_dict(self.image_processor_dict			)
             self.assertEqual(image_processor.size      ,       {'shortest_edge': 20}			)
             self.assertEqual(image_processor.crop_size      ,       {'height': 18, 'width': 18}			)

             _lowerCamelCase	:		Optional[Any]          =self.image_processing_class.from_dict(self.image_processor_dict      ,       size=42      ,       crop_size=84			)
             self.assertEqual(image_processor.size      ,       {'shortest_edge': 42}			)
             self.assertEqual(image_processor.crop_size      ,       {'height': 84, 'width': 84}			)






      def 	lowerCamelCase	( self						:					Tuple			) ->						Optional[Any]:
             """simple docstring"""




             pass






      def 	lowerCamelCase	( self						:					List[Any]			) ->						Union[str, Any]:
             """simple docstring"""




             _lowerCamelCase	:		str          =self.image_processing_class(**self.image_processor_dict			)
             # create random PIL images
             _lowerCamelCase	:		Any          =self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_			)
             for image in image_inputs:
                    self.assertIsInstance(lowercase_      ,       Image.Image			)

             # Test not batched input
             _lowerCamelCase	:		Optional[Any]          =image_processing(image_inputs[0]      ,       return_tensors='pt'			).pixel_values
             self.assertEqual(
                 encoded_images.shape      ,       (
                     1,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size['height'],
                     self.image_processor_tester.crop_size['width'],
                 )      ,       )

             # Test batched
             _lowerCamelCase	:		Optional[Any]          =image_processing(lowercase_      ,       return_tensors='pt'			).pixel_values
             self.assertEqual(
                 encoded_images.shape      ,       (
                     self.image_processor_tester.batch_size,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size['height'],
                     self.image_processor_tester.crop_size['width'],
                 )      ,       )






      def 	lowerCamelCase	( self						:					List[Any]			) ->						Optional[int]:
             """simple docstring"""




             _lowerCamelCase	:		Tuple          =self.image_processing_class(**self.image_processor_dict			)
             # create random numpy tensors
             _lowerCamelCase	:		Tuple          =self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_      ,       numpify=lowercase_			)
             for image in image_inputs:
                    self.assertIsInstance(lowercase_      ,       np.ndarray			)

             # Test not batched input
             _lowerCamelCase	:		Any          =image_processing(image_inputs[0]      ,       return_tensors='pt'			).pixel_values
             self.assertEqual(
                 encoded_images.shape      ,       (
                     1,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size['height'],
                     self.image_processor_tester.crop_size['width'],
                 )      ,       )

             # Test batched
             _lowerCamelCase	:		str          =image_processing(lowercase_      ,       return_tensors='pt'			).pixel_values
             self.assertEqual(
                 encoded_images.shape      ,       (
                     self.image_processor_tester.batch_size,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size['height'],
                     self.image_processor_tester.crop_size['width'],
                 )      ,       )






      def 	lowerCamelCase	( self						:					List[str]			) ->						Tuple:
             """simple docstring"""




             _lowerCamelCase	:		int          =self.image_processing_class(**self.image_processor_dict			)
             # create random PyTorch tensors
             _lowerCamelCase	:		Dict          =self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_      ,       torchify=lowercase_			)
             for image in image_inputs:
                    self.assertIsInstance(lowercase_      ,       torch.Tensor			)

             # Test not batched input
             _lowerCamelCase	:		List[str]          =image_processing(image_inputs[0]      ,       return_tensors='pt'			).pixel_values
             self.assertEqual(
                 encoded_images.shape      ,       (
                     1,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size['height'],
                     self.image_processor_tester.crop_size['width'],
                 )      ,       )

             # Test batched
             _lowerCamelCase	:		str          =image_processing(lowercase_      ,       return_tensors='pt'			).pixel_values
             self.assertEqual(
                 encoded_images.shape      ,       (
                     self.image_processor_tester.batch_size,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size['height'],
                     self.image_processor_tester.crop_size['width'],
                 )      ,       )




@require_torch
@require_vision
class A  (       UpperCamelCase_   ,							unittest.TestCase					):
      UpperCamelCase__							:  List[str]				=CLIPImageProcessor if is_vision_available() else None






      def 	lowerCamelCase	( self						:					Union[str, Any]			) ->						str:
             """simple docstring"""




             _lowerCamelCase	:		int          =CLIPImageProcessingTester(self      ,       num_channels=4			)
             _lowerCamelCase	:		Any          =3






      @property
      def 	lowerCamelCase	( self						:					Union[str, Any]			) ->						Tuple:
             """simple docstring"""




             return self.image_processor_tester.prepare_image_processor_dict()






      def 	lowerCamelCase	( self						:					Optional[Any]			) ->						Any:
             """simple docstring"""




             _lowerCamelCase	:		Tuple          =self.image_processing_class(**self.image_processor_dict			)
             self.assertTrue(hasattr(lowercase_      ,       'do_resize'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'size'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'do_center_crop'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'center_crop'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'do_normalize'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'image_mean'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'image_std'			)			)
             self.assertTrue(hasattr(lowercase_      ,       'do_convert_rgb'			)			)






      def 	lowerCamelCase	( self						:					Optional[int]			) ->						Optional[int]:
             """simple docstring"""




             pass






      def 	lowerCamelCase	( self						:					Any			) ->						Any:
             """simple docstring"""




             _lowerCamelCase	:		Union[str, Any]          =self.image_processing_class(**self.image_processor_dict			)
             # create random PIL images
             _lowerCamelCase	:		Optional[Any]          =self.image_processor_tester.prepare_inputs(equal_resolution=lowercase_			)
             for image in image_inputs:
                    self.assertIsInstance(lowercase_      ,       Image.Image			)

             # Test not batched input
             _lowerCamelCase	:		Any          =image_processing(image_inputs[0]      ,       return_tensors='pt'			).pixel_values
             self.assertEqual(
                 encoded_images.shape      ,       (
                     1,
                     self.expected_encoded_image_num_channels,
                     self.image_processor_tester.crop_size['height'],
                     self.image_processor_tester.crop_size['width'],
                 )      ,       )

             # Test batched
             _lowerCamelCase	:		Optional[Any]          =image_processing(lowercase_      ,       return_tensors='pt'			).pixel_values
             self.assertEqual(
                 encoded_images.shape      ,       (
                     self.image_processor_tester.batch_size,
                     self.expected_encoded_image_num_channels,
                     self.image_processor_tester.crop_size['height'],
                     self.image_processor_tester.crop_size['width'],
                 )      ,       )


