




'''simple docstring'''



import logging
from pathlib import Path
from typing import Any, List, Tuple

import yaml


# loading package files: https://stackoverflow.com/a/20885799
try:
     import importlib.resources as pkg_resources
except ImportError:
     # Try backported to PY<37 `importlib_resources`.
     import importlib_resources as pkg_resources

from . import resources


UpperCAmelCase_    :					Any					      =						'''https://github.com/huggingface/datasets/tree/main/src/datasets/utils'''
UpperCAmelCase_    :					Dict					      =						F"""{BASE_REF_URL}/{__file__}"""
UpperCAmelCase_    :					Optional[Any]					      =						logging.getLogger(__name__)







def      _UpperCamelCase	(_lowerCamelCase							:       str		)->				Tuple[Any, str]:




     '''simple docstring'''





     __snake_case         =					pkg_resources.read_text(_lowerCamelCase				,		_lowerCamelCase		)
     return yaml.safe_load(_lowerCamelCase		), f'''{BASE_REF_URL}/resources/{resource}'''


UpperCAmelCase_      ,   UpperCAmelCase_    :					Optional[int]					      =						load_yaml_resource('''readme_structure.yaml''')

UpperCAmelCase_    :					List[Any]					      =						[
    '''[Needs More Information]''',
    '''[More Information Needed]''',
    '''(https://github.com/huggingface/datasets/blob/main/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)''',
]

# Dictionary representation of section/readme, error_list, warning_list
UpperCAmelCase_    :					Dict					      =						Tuple[dict, List[str], List[str]]





class       lowerCAmelCase				:


       def __init__(				self      ,					__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE = None      ,					__SCREAMING_SNAKE_CASE = False					) ->					List[str]:



            '''simple docstring'''




            __snake_case         =					name
            __snake_case         =					level
            __snake_case         =					lines
            __snake_case         =					''''''
            __snake_case         =					True
            __snake_case         =					{}
            __snake_case         =					[]
            __snake_case         =					[]
            if self.lines is not None:
                 self.parse(suppress_parsing_errors=__SCREAMING_SNAKE_CASE					)


       def  lowerCAmelCase (				self      ,					__SCREAMING_SNAKE_CASE = False					) ->					int:



            '''simple docstring'''




            __snake_case         =					''''''
            __snake_case         =					[]
            __snake_case         =					False
            for line in self.lines:
                 if line.strip(''' \n'''					) == "":
                      continue
                 elif line.strip(''' \n'''					)[:3] == "```":
                      __snake_case         =					not code_start
                 elif line.split()[0] == self.level + "#" and not code_start:
                      if current_sub_level != "":
                           __snake_case         =					Section(__SCREAMING_SNAKE_CASE      ,					self.level + '''#'''      ,					__SCREAMING_SNAKE_CASE					)
                           __snake_case         =					[]
                      else:
                           if current_lines != []:
                                self.text += "".join(__SCREAMING_SNAKE_CASE					).strip()
                                if self.text != "" and self.text not in FILLER_TEXT:
                                     __snake_case         =					False
                                __snake_case         =					[]

                      __snake_case         =					''' '''.join(line.split()[1:]					).strip(''' \n'''					)
                 else:
                      current_lines.append(__SCREAMING_SNAKE_CASE					)
            else:
                 if current_sub_level != "":
                      if current_sub_level in self.content:
                           self.parsing_error_list.append(
                               F'''Multiple sections with the same heading `{current_sub_level}` have been found. Please keep only one of these sections.'''					)
                      __snake_case         =					Section(__SCREAMING_SNAKE_CASE      ,					self.level + '''#'''      ,					__SCREAMING_SNAKE_CASE					)
                 else:
                      if current_lines != []:
                           self.text += "".join(__SCREAMING_SNAKE_CASE					).strip()
                           if self.text != "" and self.text not in FILLER_TEXT:
                                __snake_case         =					False

            if self.level == "" and not suppress_parsing_errors:
                 if self.parsing_error_list != [] or self.parsing_warning_list != []:
                      __snake_case         =					__snake_case         =					'''\n'''.join('''-\t''' + x for x in self.parsing_error_list + self.parsing_warning_list					)
                      __snake_case         =					F'''The following issues were found while parsing the README at `{self.name}`:\n''' + errors
                      raise ValueError(__SCREAMING_SNAKE_CASE					)


       def  lowerCAmelCase (				self      ,					__SCREAMING_SNAKE_CASE					) ->					ReadmeValidatorOutput:



            '''simple docstring'''




            __snake_case         =					[]
            __snake_case         =					[]
            if structure["allow_empty"] is False:
                 # If content is expected
                 if self.is_empty_text and self.content == {}:
                      # If no content is found, mention it in the error_list
                      error_list.append(F'''Expected some content in section `{self.name}` but it is empty.'''					)

            if structure["allow_empty_text"] is False:
                 # If some text is expected
                 if self.is_empty_text:
                      # If no text is found, mention it in the error_list
                      error_list.append(
                          F'''Expected some text in section `{self.name}` but it is empty (text in subsections are ignored).'''					)
        # Subsections Validation
            if structure["subsections"] is not None:
                 # If subsections are expected
                 if self.content == {}:
                      # If no subsections are present
                      __snake_case         =					[subsection['''name'''] for subsection in structure['''subsections''']]
                      # Mention the expected values in the error_list
                      error_list.append(
                          F'''Section `{self.name}` expected the following subsections: {", ".join(["`"+x+"`" for x in values]					)}. Found \'None\'.'''					)
                 else:
                      # If some subsections are present
                      __snake_case         =					[subsection['''name'''] for subsection in structure['''subsections''']]
                      __snake_case         =					False
                      for idx, name in enumerate(__SCREAMING_SNAKE_CASE					):
                           if name not in self.content:
                                # If the expected subsection is not present
                                error_list.append(F'''Section `{self.name}` is missing subsection: `{name}`.'''					)
                                __snake_case         =					True
                           else:
                                # If the subsection is present, validate subsection, return the result
                                # and concat the errors from subsection to section error_list

                                # Skip sublevel validation if current level is `###`
                                if self.level == "###":
                                     continue
                                else:
                                     __snake_case   ,      __snake_case   ,      __snake_case         =					self.content[name].validate(
                                         structure['''subsections'''][idx]					)
                                error_list += subsec_error_list
                                warning_list += subsec_warning_list

                      if has_missing_subsections:  # we only allow to have extra subsections if all the other ones are here
                           for name in self.content:
                                if name not in structure_names:
                                     # If an extra subsection is present
                                     warning_list.append(
                                         F'''`{self.name}` has an extra subsection: `{name}`. Skipping further validation checks for this subsection as expected structure is unknown.'''					)
            if error_list:
                 # If there are errors, do not return the dictionary as it is invalid
                 return {}, error_list, warning_list
            else:
                 return self.to_dict(), error_list, warning_list




       def  lowerCAmelCase (				self					) ->					dict:



            '''simple docstring'''




            return {
                "name": self.name,
                "text": self.text,
                "is_empty_text": self.is_empty_text,
                "subsections": [value.to_dict() for value in self.content.values()],
            }





class       lowerCAmelCase				(	__lowerCAmelCase):  # Level 0


       def __init__(				self      ,					__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE = None      ,					__SCREAMING_SNAKE_CASE = False					) ->					str:



            '''simple docstring'''




            super().__init__(name=__SCREAMING_SNAKE_CASE      ,					level=''''''					)  # Not using lines here as we need to use a child class parse
            __snake_case         =					structure
            __snake_case         =					-2
            __snake_case         =					0
            __snake_case         =					lines
            if self.lines is not None:
                 self.parse(suppress_parsing_errors=__SCREAMING_SNAKE_CASE					)


       def  lowerCAmelCase (				self					) ->					Union[str, Any]:



            '''simple docstring'''




            if self.structure is None:
                 __snake_case   ,      __snake_case   ,      __snake_case         =					self._validate(__SCREAMING_SNAKE_CASE					)
            else:
                 __snake_case   ,      __snake_case   ,      __snake_case         =					self._validate(self.structure					)
            if error_list != [] or warning_list != []:
                 __snake_case         =					'''\n'''.join(['''-\t''' + x for x in error_list + warning_list]					)
                 __snake_case         =					F'''The following issues were found for the README at `{self.name}`:\n''' + errors
                 raise ValueError(__SCREAMING_SNAKE_CASE					)


       @classmethod
       def  lowerCAmelCase (				cls      ,					__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE = None      ,					__SCREAMING_SNAKE_CASE = False					) ->					List[Any]:



            '''simple docstring'''




            with open(__SCREAMING_SNAKE_CASE      ,					encoding='''utf-8'''					) as f:
                 __snake_case         =					f.readlines()
            return cls(__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE      ,					suppress_parsing_errors=__SCREAMING_SNAKE_CASE					)


       @classmethod
       def  lowerCAmelCase (				cls      ,					__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE = None      ,					__SCREAMING_SNAKE_CASE = "root"      ,					__SCREAMING_SNAKE_CASE = False					) ->					Tuple:



            '''simple docstring'''




            __snake_case         =					string.split('''\n'''					)
            return cls(__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE      ,					suppress_parsing_errors=__SCREAMING_SNAKE_CASE					)


       def  lowerCAmelCase (				self      ,					__SCREAMING_SNAKE_CASE = False					) ->					Tuple:



            '''simple docstring'''




            __snake_case         =					0

            for line in self.lines:
                 self.yaml_tags_line_count += 1
                 if line.strip(''' \n'''					) == "---":
                      self.tag_count += 1
                      if self.tag_count == 2:
                           break
                 line_count += 1
            if self.tag_count == 2:
                 __snake_case         =					self.lines[line_count + 1 :]  # Get the last + 1 th item.
            else:
                 __snake_case         =					self.lines[self.tag_count :]
            super().parse(suppress_parsing_errors=__SCREAMING_SNAKE_CASE					)


       def __str__(				self					) ->					int:



            '''simple docstring'''




            return str(self.to_dict()					)




       def  lowerCAmelCase (				self      ,					__SCREAMING_SNAKE_CASE					) ->					Dict:



            '''simple docstring'''




            __snake_case         =					[]
            __snake_case         =					[]
            if self.yaml_tags_line_count == 0:
                 warning_list.append('''Empty YAML markers are present in the README.'''					)
            elif self.tag_count == 0:
                 warning_list.append('''No YAML markers are present in the README.'''					)
            elif self.tag_count == 1:
                 warning_list.append('''Only the start of YAML tags present in the README.'''					)
            # Check how many first level sections are present.
            __snake_case         =					len(self.content.keys()					)
            if num_first_level_keys > 1:
                 # If more than one, add to the error list, continue
                 error_list.append(
                     F'''The README has several first-level headings: {", ".join(["`"+x+"`" for x in list(self.content.keys()					)]					)}. Only one heading is expected. Skipping further validation for this README.'''					)
            elif num_first_level_keys < 1:
                 # If less than one, append error.
                 error_list.append(
                     '''The README has no first-level headings. One heading is expected. Skipping further validation for this README.'''					)

            else:
                 # If one exactly
                 __snake_case         =					list(self.content.keys()					)[0]  # Get the key
                 if start_key.startswith('''Dataset Card for'''					):  # Check correct start
                      # If the starting is correct, validate all the sections
                      __snake_case   ,      __snake_case   ,      __snake_case         =					self.content[start_key].validate(
                          readme_structure['''subsections'''][0]					)
                      error_list += sec_error_list
                      warning_list += sec_warning_list
                 else:
                      # If not found, append error
                      error_list.append(
                          '''No first-level heading starting with `Dataset Card for` found in README. Skipping further validation for this README.'''					)
            if error_list:
                 # If there are errors, do not return the dictionary as it is invalid
                 return {}, error_list, warning_list
            else:
                 return self.to_dict(), error_list, warning_list


if __name__ == "__main__":
     from argparse import ArgumentParser

     UpperCAmelCase_    :					Union[str, Any]					      =						ArgumentParser(usage='''Validate the content (excluding YAML tags) of a README.md file.''')
     ap.add_argument('''readme_filepath''')
     UpperCAmelCase_    :					int					      =						ap.parse_args()
     UpperCAmelCase_    :					List[str]					      =						Path(args.readme_filepath)
     UpperCAmelCase_    :					Union[str, Any]					      =						ReadMe.from_readme(readme_filepath)












'''simple docstring'''



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       lowerCAmelCase				(	unittest.TestCase):


       def __init__(				self      ,					__SCREAMING_SNAKE_CASE      ,					__SCREAMING_SNAKE_CASE=7      ,					__SCREAMING_SNAKE_CASE=3      ,					__SCREAMING_SNAKE_CASE=18      ,					__SCREAMING_SNAKE_CASE=30      ,					__SCREAMING_SNAKE_CASE=400      ,					__SCREAMING_SNAKE_CASE=True      ,					__SCREAMING_SNAKE_CASE=None      ,					__SCREAMING_SNAKE_CASE=True      ,					__SCREAMING_SNAKE_CASE=None      ,					__SCREAMING_SNAKE_CASE=True      ,					__SCREAMING_SNAKE_CASE=[0.48_145_466, 0.4_578_275, 0.40_821_073]      ,					__SCREAMING_SNAKE_CASE=[0.26_862_954, 0.26_130_258, 0.27_577_711]      ,					__SCREAMING_SNAKE_CASE=True      ,					) ->					Optional[Any]:



            '''simple docstring'''




            __snake_case         =					size if size is not None else {'''shortest_edge''': 20}
            __snake_case         =					crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
            __snake_case         =					parent
            __snake_case         =					batch_size
            __snake_case         =					num_channels
            __snake_case         =					image_size
            __snake_case         =					min_resolution
            __snake_case         =					max_resolution
            __snake_case         =					do_resize
            __snake_case         =					size
            __snake_case         =					do_center_crop
            __snake_case         =					crop_size
            __snake_case         =					do_normalize
            __snake_case         =					image_mean
            __snake_case         =					image_std
            __snake_case         =					do_convert_rgb


       def  lowerCAmelCase (				self					) ->					Optional[int]:



            '''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      ,					__SCREAMING_SNAKE_CASE=False      ,					__SCREAMING_SNAKE_CASE=False      ,					__SCREAMING_SNAKE_CASE=False					) ->					str:



            '''simple docstring'''




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

            if equal_resolution:
                 __snake_case         =					[]
                 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:
                 __snake_case         =					[]
                 for i in range(self.batch_size					):
                      __snake_case   ,      __snake_case         =					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
                 __snake_case         =					[Image.fromarray(np.moveaxis(__SCREAMING_SNAKE_CASE      ,					0      ,					-1					)					) for x in image_inputs]

            if torchify:
                 __snake_case         =					[torch.from_numpy(__SCREAMING_SNAKE_CASE					) for x in image_inputs]

            return image_inputs





@require_torch
@require_vision
class       lowerCAmelCase				(	__lowerCAmelCase			,				unittest.TestCase):
       __lowercase					: Dict	    =     CLIPImageProcessor if is_vision_available() else None


       def  lowerCAmelCase (				self					) ->					int:



            '''simple docstring'''




            __snake_case         =					CLIPImageProcessingTester(self					)


       @property
       def  lowerCAmelCase (				self					) ->					List[str]:



            '''simple docstring'''




            return self.image_processor_tester.prepare_image_processor_dict()


       def  lowerCAmelCase (				self					) ->					Optional[Any]:



            '''simple docstring'''




            __snake_case         =					self.image_processing_class(**self.image_processor_dict					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''do_resize'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''size'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''do_center_crop'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''center_crop'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''do_normalize'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''image_mean'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''image_std'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''do_convert_rgb'''					)					)


       def  lowerCAmelCase (				self					) ->					Optional[int]:



            '''simple docstring'''




            __snake_case         =					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}					)

            __snake_case         =					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					) ->					Dict:



            '''simple docstring'''




            pass


       def  lowerCAmelCase (				self					) ->					str:



            '''simple docstring'''




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

            # Test not batched input
            __snake_case         =					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
            __snake_case         =					image_processing(__SCREAMING_SNAKE_CASE      ,					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					) ->					Dict:



            '''simple docstring'''




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

            # Test not batched input
            __snake_case         =					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
            __snake_case         =					image_processing(__SCREAMING_SNAKE_CASE      ,					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					) ->					int:



            '''simple docstring'''




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

            # Test not batched input
            __snake_case         =					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
            __snake_case         =					image_processing(__SCREAMING_SNAKE_CASE      ,					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       lowerCAmelCase				(	__lowerCAmelCase			,				unittest.TestCase):
       __lowercase					: Dict	    =     CLIPImageProcessor if is_vision_available() else None


       def  lowerCAmelCase (				self					) ->					Any:



            '''simple docstring'''




            __snake_case         =					CLIPImageProcessingTester(self      ,					num_channels=4					)
            __snake_case         =					3


       @property
       def  lowerCAmelCase (				self					) ->					str:



            '''simple docstring'''




            return self.image_processor_tester.prepare_image_processor_dict()


       def  lowerCAmelCase (				self					) ->					List[Any]:



            '''simple docstring'''




            __snake_case         =					self.image_processing_class(**self.image_processor_dict					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''do_resize'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''size'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''do_center_crop'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''center_crop'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''do_normalize'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''image_mean'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''image_std'''					)					)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE      ,					'''do_convert_rgb'''					)					)


       def  lowerCAmelCase (				self					) ->					Tuple:



            '''simple docstring'''




            pass




       def  lowerCAmelCase (				self					) ->					Optional[int]:



            '''simple docstring'''




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

            # Test not batched input
            __snake_case         =					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
            __snake_case         =					image_processing(__SCREAMING_SNAKE_CASE      ,					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'''],
                )      ,					)






