

import json
import os
import pickle
import subprocess
from hashlib import mda
from pathlib import Path
from tempfile import gettempdir
from textwrap import dedent
from types import CodeType, FunctionType
from unittest import TestCase
from unittest.mock import patch

import pytest
from multiprocess import Pool
from packaging import version

import datasets
from datasets.fingerprint import Hasher, fingerprint_transform
from datasets.table import InMemoryTable

from .utils import (
    require_regex,
    require_spacy,
    require_spacy_model,
    require_tiktoken,
    require_torch,
    require_transformers,
)

class 					__UpperCamelCase					:







	def __init__( self:			Any	,			__UpperCamelCase:			str   ):

						'''simple docstring'''





						__magic_name__				=     foo







	def __call__( self:			Union[str, Any]   ):

						'''simple docstring'''





						return self.foo




class 					__UpperCamelCase					(       datasets.Dataset      ):







	@fingerprint_transform(inplace=_lowercase   )
	def 						_SCREAMING_SNAKE_CASE				( self:			List[Any]	,			__UpperCamelCase:			List[str]	,			*__UpperCamelCase:			Optional[int]	,			**__UpperCamelCase:			List[Any]   ):

						'''simple docstring'''





						return DatasetChild(self.data	,			fingerprint=_lowercase   )







	@fingerprint_transform(inplace=_lowercase   )
	def 						_SCREAMING_SNAKE_CASE				( self:			Optional[int]	,			__UpperCamelCase:			Optional[int]	,			*__UpperCamelCase:			int	,			**__UpperCamelCase:			Optional[int]   ):

						'''simple docstring'''





						return DatasetChild(self.data	,			fingerprint=_lowercase   )




class 					__UpperCamelCase					:







	def __init__( self:			str	,			__UpperCamelCase:			Optional[Any]   ):

						'''simple docstring'''





						__magic_name__				=     callable







	def __call__( self:			Optional[Any]	,			*__UpperCamelCase:			Dict	,			**__UpperCamelCase:			str   ):

						'''simple docstring'''





						if self.callable is not None:
											return self.callable(*_lowercase	,			**_lowercase   )







	def __getstate__( self:			Optional[Any]   ):

						'''simple docstring'''





						raise pickle.PicklingError()




class 					__UpperCamelCase					(       lowerCAmelCase__      ):







	@require_transformers
	@pytest.mark.integration
	def 						_SCREAMING_SNAKE_CASE				( self:			str   ):

						'''simple docstring'''





						from transformers import AutoTokenizer

						def encode(__UpperCamelCase:			int   ):
											return tokenizer(_lowercase   )

						# TODO: add hash consistency tests across sessions
						__magic_name__				=     AutoTokenizer.from_pretrained('bert-base-uncased'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(lambda __UpperCamelCase   : tokenizer(_lowercase   )   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     AutoTokenizer.from_pretrained('bert-base-cased'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(lambda __UpperCamelCase   : tokenizer(_lowercase   )   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     AutoTokenizer.from_pretrained('bert-base-uncased'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(lambda __UpperCamelCase   : tokenizer(_lowercase   )   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	@require_transformers
	@pytest.mark.integration
	def 						_SCREAMING_SNAKE_CASE				( self:			Tuple   ):

						'''simple docstring'''





						from transformers import AutoTokenizer

						__magic_name__				=     AutoTokenizer.from_pretrained('gpt2'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						tokenizer('Hello world !'   )  # call once to change the tokenizer's cache
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )







	@require_regex
	def 						_SCREAMING_SNAKE_CASE				( self:			List[str]   ):

						'''simple docstring'''





						import regex

						__magic_name__				=     regex.Regex('foo'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     regex.Regex('bar'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     regex.Regex('foo'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )




class 					__UpperCamelCase					(       lowerCAmelCase__      ):







	def 						_SCREAMING_SNAKE_CASE				( self:			Optional[int]   ):

						'''simple docstring'''





						def func():
											return foo

						__magic_name__				=     [0]
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     [1]
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     [0]
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	def 						_SCREAMING_SNAKE_CASE				( self:			List[str]   ):

						'''simple docstring'''





						def func():
											pass

						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()

						def func():
											pass

						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )







	def 						_SCREAMING_SNAKE_CASE				( self:			List[str]   ):

						'''simple docstring'''





						__magic_name__				=     mda(datasets.utils.py_utils.dumps(Foo([0]   )   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(Foo([1]   )   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(Foo([0]   )   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	def 						_SCREAMING_SNAKE_CASE				( self:			List[Any]   ):

						'''simple docstring'''





						__magic_name__				=     mda(datasets.utils.py_utils.dumps(Foo([0]   ).__call__   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(Foo([1]   ).__call__   )   ).hexdigest()
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(Foo([0]   ).__call__   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	def 						_SCREAMING_SNAKE_CASE				( self:			str   ):

						'''simple docstring'''





						__magic_name__				=     (
						    'co_argcount',
						    'co_kwonlyargcount',
						    'co_nlocals',
						    'co_stacksize',
						    'co_flags',
						    'co_code',
						    'co_consts',
						    'co_names',
						    'co_varnames',
						    'co_filename',
						    'co_name',
						    'co_firstlineno',
						    'co_lnotab',
						    'co_freevars',
						    'co_cellvars',
						)

						def _create_code_pyaa(*__UpperCamelCase:			Any   ):
											if hasattr(args[-3]	,			'encode'   ):
																__magic_name__				=     list(_lowercase   )
																__magic_name__				=     args[-3].encode()  # co_lnotab
																__magic_name__				=     args[-10].encode()  # co_code
											if hasattr(_lowercase	,			'co_posonlyargcount'   ):
																if len(_lowercase   ) == 16:
																					return CodeType(*_lowercase   )
																elif len(_lowercase   ) == 15:
																					return CodeType(args[0]	,			0	,			*args[1:]   )
																return CodeType(args[0]	,			0	,			0	,			*args[1:]   )
											elif hasattr(_lowercase	,			'co_kwonlyargcount'   ):
																if len(_lowercase   ) == 16:
																					return CodeType(args[0]	,			*args[2:]   )
																elif len(_lowercase   ) == 15:
																					return CodeType(*_lowercase   )
																return CodeType(args[0]	,			0	,			*args[1:]   )
											if len(_lowercase   ) == 16:
																return CodeType(args[0]	,			*args[3:]   )
											elif len(_lowercase   ) == 15:
																return CodeType(args[0]	,			*args[2:]   )
											return CodeType(*_lowercase   )

						def create_ipython_func(__UpperCamelCase:			Dict	,			__UpperCamelCase:			List[str]   ):
											def func():
																return returned_obj

											__magic_name__				=     func.__code__
											# Use _create_code from dill in order to make it work for different python versions
											if datasets.config.PY_VERSION < version.parse('3.8'   ):
																__magic_name__				=     _create_code_pyaa(
																    *[getattr(_lowercase	,			_lowercase   ) if k != 'co_filename' else co_filename for k in code_args_pyaa]   )
											else:
																__magic_name__				=     code.replace(co_filename=_lowercase   )
											return FunctionType(_lowercase	,			func.__globals__	,			func.__name__	,			func.__defaults__	,			func.__closure__   )

						__magic_name__,						__magic_name__				=     '<ipython-input-2-e0383a102aae>', [0]
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowercase	,			_lowercase   )   )   ).hexdigest()
						__magic_name__,						__magic_name__				=     '<ipython-input-2-e0383a102aae>', [1]
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowercase	,			_lowercase   )   )   ).hexdigest()
						__magic_name__,						__magic_name__				=     '<ipython-input-5-713f6613acf3>', [0]
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowercase	,			_lowercase   )   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )

						__magic_name__,						__magic_name__				=     os.path.join(gettempdir()	,			'ipykernel_12345'	,			'321456789.py'   ), [0]
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowercase	,			_lowercase   )   )   ).hexdigest()
						__magic_name__,						__magic_name__				=     os.path.join(gettempdir()	,			'ipykernel_12345'	,			'321456789.py'   ), [1]
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowercase	,			_lowercase   )   )   ).hexdigest()
						__magic_name__,						__magic_name__				=     os.path.join(gettempdir()	,			'ipykernel_12345'	,			'654123987.py'   ), [0]
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(create_ipython_func(_lowercase	,			_lowercase   )   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	def 						_SCREAMING_SNAKE_CASE				( self:			Tuple   ):

						'''simple docstring'''





						__magic_name__,						__magic_name__				=     [0], [1]

						def func():
											return foo, bar

						__magic_name__				=     '__main__'

						def globalvars_mocka_side_effect(__UpperCamelCase:			int	,			*__UpperCamelCase:			Any	,			**__UpperCamelCase:			Union[str, Any]   ):
											return {"foo": foo, "bar": bar}

						def globalvars_mocka_side_effect(__UpperCamelCase:			List[Any]	,			*__UpperCamelCase:			Optional[int]	,			**__UpperCamelCase:			Dict   ):
											return {"bar": bar, "foo": foo}

						with patch('dill.detect.globalvars'	,			side_effect=_lowercase   ) as globalvars_mocka:
											__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
											self.assertGreater(globalvars_mocka.call_count	,			0   )
						with patch('dill.detect.globalvars'	,			side_effect=_lowercase   ) as globalvars_mocka:
											__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
											self.assertGreater(globalvars_mocka.call_count	,			0   )
						self.assertEqual(_lowercase	,			_lowercase   )




class 					__UpperCamelCase					(       lowerCAmelCase__      ):







	def 						_SCREAMING_SNAKE_CASE				( self:			Union[str, Any]   ):

						'''simple docstring'''





						__magic_name__				=     Hasher.hash('hello'   )
						__magic_name__				=     Hasher.hash('hello'   )
						__magic_name__				=     Hasher.hash('there'   )
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	def 						_SCREAMING_SNAKE_CASE				( self:			str   ):

						'''simple docstring'''





						__magic_name__				=     Hasher.hash(Foo('hello'   )   )
						__magic_name__				=     Hasher.hash(Foo('hello'   )   )
						__magic_name__				=     Hasher.hash(Foo('there'   )   )
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	def 						_SCREAMING_SNAKE_CASE				( self:			Dict   ):

						'''simple docstring'''





						__magic_name__				=     Hasher()
						for x in ["hello", Foo('hello'   )]:
											hasher.update(_lowercase   )
						__magic_name__				=     hasher.hexdigest()
						__magic_name__				=     Hasher()
						for x in ["hello", Foo('hello'   )]:
											hasher.update(_lowercase   )
						__magic_name__				=     hasher.hexdigest()
						__magic_name__				=     Hasher()
						for x in ["there", Foo('there'   )]:
											hasher.update(_lowercase   )
						__magic_name__				=     hasher.hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	def 						_SCREAMING_SNAKE_CASE				( self:			Tuple   ):

						'''simple docstring'''





						with self.assertRaises(pickle.PicklingError   ):
											Hasher.hash(UnpicklableCallable(Foo('hello'   )   )   )







	def 						_SCREAMING_SNAKE_CASE				( self:			Tuple   ):

						'''simple docstring'''





						__magic_name__				=     'abc'
						__magic_name__				=     [string, string]  # two strings have the same ids
						__magic_name__				=     [string, string]
						__magic_name__				=     json.loads(F'["{string}", "{string}"]'   )  # two strings have different ids
						self.assertIs(obja[0]	,			_lowercase   )
						self.assertIs(obja[0]	,			obja[1]   )
						self.assertIs(obja[0]	,			_lowercase   )
						self.assertIs(obja[0]	,			obja[1]   )
						self.assertIsNot(obja[0]	,			_lowercase   )
						self.assertIsNot(obja[0]	,			obja[1]   )
						__magic_name__				=     Hasher.hash(_lowercase   )
						__magic_name__				=     Hasher.hash(_lowercase   )
						__magic_name__				=     Hasher.hash(_lowercase   )
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertEqual(_lowercase	,			_lowercase   )







	@require_tiktoken
	def 						_SCREAMING_SNAKE_CASE				( self:			Optional[int]   ):

						'''simple docstring'''





						import tiktoken

						__magic_name__				=     tiktoken.get_encoding('gpt2'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     tiktoken.get_encoding('r50k_base'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     tiktoken.get_encoding('gpt2'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	@require_torch
	def 						_SCREAMING_SNAKE_CASE				( self:			List[str]   ):

						'''simple docstring'''





						import torch

						__magic_name__				=     torch.tensor([1.0]   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     torch.tensor([2.0]   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     torch.tensor([1.0]   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )







	@require_spacy
	@require_spacy_model('en_core_web_sm'   )
	@require_spacy_model('fr_core_news_sm'   )
	@pytest.mark.integration
	def 						_SCREAMING_SNAKE_CASE				( self:			Optional[int]   ):

						'''simple docstring'''





						import spacy

						__magic_name__				=     spacy.load('en_core_web_sm'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     spacy.load('fr_core_news_sm'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						__magic_name__				=     spacy.load('en_core_web_sm'   )
						__magic_name__				=     mda(datasets.utils.py_utils.dumps(_lowercase   )   ).hexdigest()
						self.assertEqual(_lowercase	,			_lowercase   )
						self.assertNotEqual(_lowercase	,			_lowercase   )




@pytest.mark.integration
def        _lowercase  (					a_					:       List[str]					)					->						Optional[int]:




					'''simple docstring'''







					__magic_name__				=     tmp_path / 'dir1'
					__magic_name__				=     tmp_path / 'dir2'
					dira.mkdir()
					dira.mkdir()
					__magic_name__				=     'script.py'
					__magic_name__				=     dedent(
					    '\n    from datasets.fingerprint import Hasher\n    def foo():\n        pass\n    print(Hasher.hash(foo))\n    '					)
					__magic_name__				=     dira / script_filename
					__magic_name__				=     dira / script_filename
					with script_patha.open('w'					) as f:
										f.write(UpperCamelCase__					)
					with script_patha.open('w'					) as f:
										f.write(UpperCamelCase__					)
					__magic_name__				=     subprocess.check_output(['python', str(UpperCamelCase__					)]					)
					__magic_name__				=     subprocess.check_output(['python', str(UpperCamelCase__					)]					)
					assert fingerprinta == fingerprinta




def        _lowercase  (					)					->						Tuple:




					'''simple docstring'''







					__magic_name__				=     {'a': [0, 1, 2]}
					__magic_name__				=     DatasetChild(InMemoryTable.from_pydict(UpperCamelCase__					)					)
					__magic_name__				=     dataset.funca()._fingerprint
					assert expected_fingerprint == dataset.funca()._fingerprint
					assert expected_fingerprint != dataset.funca()._fingerprint

					with Pool(2					) as p:
										assert expected_fingerprint == p.apply_async(dataset.funca					).get()._fingerprint
										assert expected_fingerprint != p.apply_async(dataset.funca					).get()._fingerprint




def        _lowercase  (					)					->						List[Any]:




					'''simple docstring'''







					__magic_name__				=     {'a': [0, 1, 2]}

					class 					__UpperCamelCase					(       datasets.Dataset      ):







						@fingerprint_transform(inplace=_lowercase   )
						def 						_SCREAMING_SNAKE_CASE				( self:			Any	,			__UpperCamelCase:			Any   ):

											'''simple docstring'''





											return DummyDatasetChild(self.data	,			fingerprint=_lowercase   )




					__magic_name__				=     DummyDatasetChild(InMemoryTable.from_pydict(UpperCamelCase__					)					).func()

					class 					__UpperCamelCase					(       datasets.Dataset      ):







						@fingerprint_transform(inplace=_lowercase	,			version='1.0.0'   )
						def 						_SCREAMING_SNAKE_CASE				( self:			List[str]	,			__UpperCamelCase:			Optional[Any]   ):

											'''simple docstring'''





											return DummyDatasetChild(self.data	,			fingerprint=_lowercase   )




					__magic_name__				=     DummyDatasetChild(InMemoryTable.from_pydict(UpperCamelCase__					)					).func()

					class 					__UpperCamelCase					(       datasets.Dataset      ):







						@fingerprint_transform(inplace=_lowercase	,			version='2.0.0'   )
						def 						_SCREAMING_SNAKE_CASE				( self:			str	,			__UpperCamelCase:			Optional[int]   ):

											'''simple docstring'''





											return DummyDatasetChild(self.data	,			fingerprint=_lowercase   )




					__magic_name__				=     DummyDatasetChild(InMemoryTable.from_pydict(UpperCamelCase__					)					).func()

					assert len({fingeprint_no_version, fingeprint_a, fingeprint_a}					) == 3




def        _lowercase  (					)					->						int:




					'''simple docstring'''







					__magic_name__				=     Hasher()
					hasher.update(lambda a_					: x					)










from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
	import PIL


__A						:		Dict          =						logging.get_logger(__name__)

class 		lowercase_       (	lowerCAmelCase__				):
					__UpperCamelCase     	= ["pixel_values"]




					def __init__(   self:		str,     _lowercase:		bool = True,     _lowercase:		Dict[str, int] = None,     _lowercase:		PILImageResampling = PIL.Image.NEAREST,     _lowercase:		bool = False,     _lowercase:		Dict[str, int] = None,     _lowercase:		Union[int, float] = 1 / 255,     _lowercase:		bool = False,     _lowercase:		bool = True,     _lowercase:		bool = True,     _lowercase:		Optional[Union[float, List[float]]] = None,     _lowercase:		Optional[Union[float, List[float]]] = None,     _lowercase:		bool = True,     **_lowercase:		Union[str, Any],     ):


									'''simple docstring'''


									super().__init__(**_lowercase)
									__lowerCAmelCase					=  size if size is not None else {"""height""": 346, """width""": 346}
									__lowerCAmelCase					=  get_size_dict(_lowercase)
									__lowerCAmelCase					=  crop_size if crop_size is not None else {"""height""": 289, """width""": 289}
									__lowerCAmelCase					=  get_size_dict(_lowercase,     param_name="""crop_size""")

									__lowerCAmelCase					=  do_resize
									__lowerCAmelCase					=  size
									__lowerCAmelCase					=  resample
									__lowerCAmelCase					=  do_center_crop
									__lowerCAmelCase					=  crop_size
									__lowerCAmelCase					=  do_rescale
									__lowerCAmelCase					=  rescale_factor
									__lowerCAmelCase					=  rescale_offset
									__lowerCAmelCase					=  do_normalize
									__lowerCAmelCase					=  image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
									__lowerCAmelCase					=  image_std if image_std is not None else IMAGENET_STANDARD_STD
									__lowerCAmelCase					=  include_top




					def     _lowercase						(   self:		Optional[Any],     _lowercase:		np.ndarray,     _lowercase:		Dict[str, int],     _lowercase:		PILImageResampling = PIL.Image.NEAREST,     _lowercase:		Optional[Union[str, ChannelDimension]] = None,     **_lowercase:		Dict,     ):


									'''simple docstring'''


									__lowerCAmelCase					=  get_size_dict(_lowercase)
									if "height" not in size or "width" not in size:
													raise ValueError(f'''The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}''')
									return resize(
									    _lowercase,     size=(size["""height"""], size["""width"""]),     resample=_lowercase,     data_format=_lowercase,     **_lowercase)




					def     _lowercase						(   self:		List[str],     _lowercase:		np.ndarray,     _lowercase:		Dict[str, int],     _lowercase:		Optional[Union[str, ChannelDimension]] = None,     **_lowercase:		Tuple,     ):


									'''simple docstring'''


									__lowerCAmelCase					=  get_size_dict(_lowercase)
									if "height" not in size or "width" not in size:
													raise ValueError(f'''The size dictionary must have keys \'height\' and \'width\'. Got {size.keys()}''')
									return center_crop(_lowercase,     size=(size["""height"""], size["""width"""]),     data_format=_lowercase,     **_lowercase)




					def     _lowercase						(   self:		Union[str, Any],     _lowercase:		np.ndarray,     _lowercase:		Union[int, float],     _lowercase:		bool = True,     _lowercase:		Optional[Union[str, ChannelDimension]] = None,     **_lowercase:		Dict,     ):


									'''simple docstring'''


									if offset:
													__lowerCAmelCase					=  (image - 127.5) * scale
													if data_format is not None:
																	__lowerCAmelCase					=  to_channel_dimension_format(_lowercase,     _lowercase)
													__lowerCAmelCase					=  rescaled_image.astype(np.floataa)
									else:
													__lowerCAmelCase					=  rescale(_lowercase,     scale=_lowercase,     data_format=_lowercase,     **_lowercase)
									return rescaled_image




					def     _lowercase						(   self:		Dict,     _lowercase:		np.ndarray,     _lowercase:		Union[float, List[float]],     _lowercase:		Union[float, List[float]],     _lowercase:		Optional[Union[str, ChannelDimension]] = None,     **_lowercase:		Any,     ):


									'''simple docstring'''


									return normalize(_lowercase,     mean=_lowercase,     std=_lowercase,     data_format=_lowercase,     **_lowercase)







					def     _lowercase						(   self:		Dict,     _lowercase:		ImageInput,     _lowercase:		bool = None,     _lowercase:		Dict[str, int] = None,     _lowercase:		str=None,     _lowercase:		bool = None,     _lowercase:		Dict[str, int] = None,     _lowercase:		bool = None,     _lowercase:		float = None,     _lowercase:		bool = None,     _lowercase:		bool = None,     _lowercase:		Optional[Union[float, List[float]]] = None,     _lowercase:		Optional[Union[float, List[float]]] = None,     _lowercase:		bool = None,     _lowercase:		Optional[Union[str, TensorType]] = None,     _lowercase:		ChannelDimension = ChannelDimension.FIRST,     **_lowercase:		Tuple,     ):


									'''simple docstring'''


									__lowerCAmelCase					=  do_resize if do_resize is not None else self.do_resize
									__lowerCAmelCase					=  resample if resample is not None else self.resample
									__lowerCAmelCase					=  do_center_crop if do_center_crop is not None else self.do_center_crop
									__lowerCAmelCase					=  do_rescale if do_rescale is not None else self.do_rescale
									__lowerCAmelCase					=  rescale_factor if rescale_factor is not None else self.rescale_factor
									__lowerCAmelCase					=  rescale_offset if rescale_offset is not None else self.rescale_offset
									__lowerCAmelCase					=  do_normalize if do_normalize is not None else self.do_normalize
									__lowerCAmelCase					=  image_mean if image_mean is not None else self.image_mean
									__lowerCAmelCase					=  image_std if image_std is not None else self.image_std
									__lowerCAmelCase					=  include_top if include_top is not None else self.include_top

									__lowerCAmelCase					=  size if size is not None else self.size
									__lowerCAmelCase					=  get_size_dict(_lowercase)
									__lowerCAmelCase					=  crop_size if crop_size is not None else self.crop_size
									__lowerCAmelCase					=  get_size_dict(_lowercase,     param_name="""crop_size""")

									__lowerCAmelCase					=  make_list_of_images(_lowercase)

									if not valid_images(_lowercase):
													raise ValueError(
													    """Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, """
													    """torch.Tensor, tf.Tensor or jax.ndarray.""")

									if do_resize and size is None or resample is None:
													raise ValueError("""Size and resample must be specified if do_resize is True.""")

									if do_center_crop and crop_size is None:
													raise ValueError("""Crop size must be specified if do_center_crop is True.""")

									if do_rescale and rescale_factor is None:
													raise ValueError("""Rescale factor must be specified if do_rescale is True.""")

									if do_normalize and (image_mean is None or image_std is None):
													raise ValueError("""Image mean and std must be specified if do_normalize is True.""")

									# All transformations expect numpy arrays.
									__lowerCAmelCase					=  [to_numpy_array(_lowercase) for image in images]

									if do_resize:
													__lowerCAmelCase					=  [self.resize(image=_lowercase,     size=_lowercase,     resample=_lowercase) for image in images]

									if do_center_crop:
													__lowerCAmelCase					=  [self.center_crop(image=_lowercase,     size=_lowercase) for image in images]

									if do_rescale:
													__lowerCAmelCase					=  [self.rescale(image=_lowercase,     scale=_lowercase,     offset=_lowercase) for image in images]

									if do_normalize:
													__lowerCAmelCase					=  [self.normalize(image=_lowercase,     mean=_lowercase,     std=_lowercase) for image in images]

									if include_top:
													__lowerCAmelCase					=  [self.normalize(image=_lowercase,     mean=[0, 0, 0],     std=_lowercase) for image in images]

									__lowerCAmelCase					=  [to_channel_dimension_format(_lowercase,     _lowercase) for image in images]

									__lowerCAmelCase					=  {"""pixel_values""": images}
									return BatchFeature(data=_lowercase,     tensor_type=_lowercase)





