
"""simple docstring"""
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    _snake_case  :






							def __init__(					self						:			str						, snake_case__						:			Optional[int]    ):






												"""simple docstring"""



												__a:						List[str]		    =					foo






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






												"""simple docstring"""



												return self.foo






class    _snake_case  (						datasets.Dataset       ):






							@fingerprint_transform(inplace=snake_case__    )
							def 							__lowercase  (					self						:			List[Any]						, snake_case__						:			Dict						, *snake_case__						:			Dict						, **snake_case__						:			str    ):






												"""simple docstring"""



												return DatasetChild(self.data						, fingerprint=snake_case__    )






							@fingerprint_transform(inplace=snake_case__    )
							def 							__lowercase  (					self						:			int						, snake_case__						:			Optional[int]						, *snake_case__						:			List[str]						, **snake_case__						:			Optional[Any]    ):






												"""simple docstring"""



												return DatasetChild(self.data						, fingerprint=snake_case__    )






class    _snake_case  :






							def __init__(					self						:			Optional[int]						, snake_case__						:			Dict    ):






												"""simple docstring"""



												__a:						List[str]		    =					callable






							def __call__(					self						:			Any						, *snake_case__						:			Tuple						, **snake_case__						:			Tuple    ):






												"""simple docstring"""



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






							def __getstate__(					self						:			str    ):






												"""simple docstring"""



												raise pickle.PicklingError()






class    _snake_case  (						_lowercase       ):






							@require_transformers
							@pytest.mark.integration
							def 							__lowercase  (					self						:			Union[str, Any]    ):






												"""simple docstring"""



												from transformers import AutoTokenizer

												def encode(snake_case__						:			Optional[int]    ):
																	return tokenizer(snake_case__    )

												# TODO: add hash consistency tests across sessions
												__a:						List[Any]		    =					AutoTokenizer.from_pretrained("""bert-base-uncased"""    )
												__a:						int		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Any		    =					mda(datasets.utils.py_utils.dumps(lambda snake_case__    : tokenizer(snake_case__    )    )    ).hexdigest()
												__a:						Dict		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Any		    =					AutoTokenizer.from_pretrained("""bert-base-cased"""    )
												__a:						Optional[int]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Any		    =					mda(datasets.utils.py_utils.dumps(lambda snake_case__    : tokenizer(snake_case__    )    )    ).hexdigest()
												__a:						str		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Optional[int]		    =					AutoTokenizer.from_pretrained("""bert-base-uncased"""    )
												__a:						Optional[int]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Any		    =					mda(datasets.utils.py_utils.dumps(lambda snake_case__    : tokenizer(snake_case__    )    )    ).hexdigest()
												__a:						List[Any]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






							@require_transformers
							@pytest.mark.integration
							def 							__lowercase  (					self						:			List[Any]    ):






												"""simple docstring"""



												from transformers import AutoTokenizer

												__a:						List[str]		    =					AutoTokenizer.from_pretrained("""gpt2"""    )
												__a:						int		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												tokenizer("""Hello world !"""    )  # call once to change the tokenizer's cache
												__a:						Tuple		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )






							@require_regex
							def 							__lowercase  (					self						:			Dict    ):






												"""simple docstring"""



												import regex

												__a:						str		    =					regex.Regex("""foo"""    )
												__a:						Tuple		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						List[Any]		    =					regex.Regex("""bar"""    )
												__a:						Union[str, Any]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Tuple		    =					regex.Regex("""foo"""    )
												__a:						Optional[Any]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






class    _snake_case  (						_lowercase       ):






							def 							__lowercase  (					self						:			Optional[int]    ):






												"""simple docstring"""



												def func():
																	return foo

												__a:						Tuple		    =					[0]
												__a:						Tuple		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Optional[int]		    =					[1]
												__a:						int		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Union[str, Any]		    =					[0]
												__a:						Any		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






							def 							__lowercase  (					self						:			Optional[Any]    ):






												"""simple docstring"""



												def func():
																	pass

												__a:						Tuple		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()

												def func():
																	pass

												__a:						List[Any]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )






							def 							__lowercase  (					self						:			Optional[int]    ):






												"""simple docstring"""



												__a:						Tuple		    =					mda(datasets.utils.py_utils.dumps(Foo([0]    )    )    ).hexdigest()
												__a:						Union[str, Any]		    =					mda(datasets.utils.py_utils.dumps(Foo([1]    )    )    ).hexdigest()
												__a:						Tuple		    =					mda(datasets.utils.py_utils.dumps(Foo([0]    )    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






							def 							__lowercase  (					self						:			Dict    ):






												"""simple docstring"""



												__a:						List[str]		    =					mda(datasets.utils.py_utils.dumps(Foo([0]    ).__call__    )    ).hexdigest()
												__a:						Any		    =					mda(datasets.utils.py_utils.dumps(Foo([1]    ).__call__    )    ).hexdigest()
												__a:						Any		    =					mda(datasets.utils.py_utils.dumps(Foo([0]    ).__call__    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






							def 							__lowercase  (					self						:			Optional[Any]    ):






												"""simple docstring"""



												__a:						int		    =					(
												    """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(*snake_case__						:			int    ):
																	if hasattr(args[-3]						, """encode"""    ):
																						__a:						str		    =					list(snake_case__    )
																						__a:						Dict		    =					args[-3].encode()  # co_lnotab
																						__a:						Optional[Any]		    =					args[-1_0].encode()  # co_code
																	if hasattr(snake_case__						, """co_posonlyargcount"""    ):
																						if len(snake_case__    ) == 1_6:
																											return CodeType(*snake_case__    )
																						elif len(snake_case__    ) == 1_5:
																											return CodeType(args[0]						, 0						, *args[1:]    )
																						return CodeType(args[0]						, 0						, 0						, *args[1:]    )
																	elif hasattr(snake_case__						, """co_kwonlyargcount"""    ):
																						if len(snake_case__    ) == 1_6:
																											return CodeType(args[0]						, *args[2:]    )
																						elif len(snake_case__    ) == 1_5:
																											return CodeType(*snake_case__    )
																						return CodeType(args[0]						, 0						, *args[1:]    )
																	if len(snake_case__    ) == 1_6:
																						return CodeType(args[0]						, *args[3:]    )
																	elif len(snake_case__    ) == 1_5:
																						return CodeType(args[0]						, *args[2:]    )
																	return CodeType(*snake_case__    )

												def create_ipython_func(snake_case__						:			int						, snake_case__						:			Union[str, Any]    ):
																	def func():
																						return returned_obj

																	__a:						Optional[Any]		    =					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"""    ):
																						__a:						List[Any]		    =					_create_code_pyaa(
																						    *[getattr(snake_case__						, snake_case__    ) if k != """co_filename""" else co_filename for k in code_args_pyaa]    )
																	else:
																						__a:						str		    =					code.replace(co_filename=snake_case__    )
																	return FunctionType(snake_case__						, func.__globals__						, func.__name__						, func.__defaults__						, func.__closure__    )

												__a    ,				__a:						Union[str, Any]		    =					"""<ipython-input-2-e0383a102aae>""", [0]
												__a:						Tuple		    =					mda(datasets.utils.py_utils.dumps(create_ipython_func(snake_case__						, snake_case__    )    )    ).hexdigest()
												__a    ,				__a:						Any		    =					"""<ipython-input-2-e0383a102aae>""", [1]
												__a:						Dict		    =					mda(datasets.utils.py_utils.dumps(create_ipython_func(snake_case__						, snake_case__    )    )    ).hexdigest()
												__a    ,				__a:						List[str]		    =					"""<ipython-input-5-713f6613acf3>""", [0]
												__a:						List[str]		    =					mda(datasets.utils.py_utils.dumps(create_ipython_func(snake_case__						, snake_case__    )    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )

												__a    ,				__a:						Tuple		    =					os.path.join(gettempdir()						, """ipykernel_12345"""						, """321456789.py"""    ), [0]
												__a:						List[Any]		    =					mda(datasets.utils.py_utils.dumps(create_ipython_func(snake_case__						, snake_case__    )    )    ).hexdigest()
												__a    ,				__a:						str		    =					os.path.join(gettempdir()						, """ipykernel_12345"""						, """321456789.py"""    ), [1]
												__a:						int		    =					mda(datasets.utils.py_utils.dumps(create_ipython_func(snake_case__						, snake_case__    )    )    ).hexdigest()
												__a    ,				__a:						int		    =					os.path.join(gettempdir()						, """ipykernel_12345"""						, """654123987.py"""    ), [0]
												__a:						int		    =					mda(datasets.utils.py_utils.dumps(create_ipython_func(snake_case__						, snake_case__    )    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






							def 							__lowercase  (					self						:			List[str]    ):






												"""simple docstring"""



												__a    ,				__a:						Optional[int]		    =					[0], [1]

												def func():
																	return foo, bar

												__a:						Optional[int]		    =					"""__main__"""

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

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

												with patch("""dill.detect.globalvars"""						, side_effect=snake_case__    ) as globalvars_mocka:
																	__a:						Union[str, Any]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
																	self.assertGreater(globalvars_mocka.call_count						, 0    )
												with patch("""dill.detect.globalvars"""						, side_effect=snake_case__    ) as globalvars_mocka:
																	__a:						List[Any]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
																	self.assertGreater(globalvars_mocka.call_count						, 0    )
												self.assertEqual(snake_case__						, snake_case__    )






class    _snake_case  (						_lowercase       ):






							def 							__lowercase  (					self						:			str    ):






												"""simple docstring"""



												__a:						str		    =					Hasher.hash("""hello"""    )
												__a:						Union[str, Any]		    =					Hasher.hash("""hello"""    )
												__a:						str		    =					Hasher.hash("""there"""    )
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






							def 							__lowercase  (					self						:			str    ):






												"""simple docstring"""



												__a:						List[str]		    =					Hasher.hash(Foo("""hello"""    )    )
												__a:						Any		    =					Hasher.hash(Foo("""hello"""    )    )
												__a:						str		    =					Hasher.hash(Foo("""there"""    )    )
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






							def 							__lowercase  (					self						:			int    ):






												"""simple docstring"""



												__a:						Union[str, Any]		    =					Hasher()
												for x in ["hello", Foo("""hello"""    )]:
																	hasher.update(snake_case__    )
												__a:						List[str]		    =					hasher.hexdigest()
												__a:						List[str]		    =					Hasher()
												for x in ["hello", Foo("""hello"""    )]:
																	hasher.update(snake_case__    )
												__a:						Optional[Any]		    =					hasher.hexdigest()
												__a:						Union[str, Any]		    =					Hasher()
												for x in ["there", Foo("""there"""    )]:
																	hasher.update(snake_case__    )
												__a:						int		    =					hasher.hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






							def 							__lowercase  (					self						:			Optional[Any]    ):






												"""simple docstring"""



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






							def 							__lowercase  (					self						:			Any    ):






												"""simple docstring"""



												__a:						int		    =					"""abc"""
												__a:						Union[str, Any]		    =					[string, string]  # two strings have the same ids
												__a:						Tuple		    =					[string, string]
												__a:						Union[str, Any]		    =					json.loads(f"""[\"{string}\", \"{string}\"]"""    )  # two strings have different ids
												self.assertIs(obja[0]						, snake_case__    )
												self.assertIs(obja[0]						, obja[1]    )
												self.assertIs(obja[0]						, snake_case__    )
												self.assertIs(obja[0]						, obja[1]    )
												self.assertIsNot(obja[0]						, snake_case__    )
												self.assertIsNot(obja[0]						, obja[1]    )
												__a:						str		    =					Hasher.hash(snake_case__    )
												__a:						int		    =					Hasher.hash(snake_case__    )
												__a:						List[Any]		    =					Hasher.hash(snake_case__    )
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertEqual(snake_case__						, snake_case__    )






							@require_tiktoken
							def 							__lowercase  (					self						:			int    ):






												"""simple docstring"""



												import tiktoken

												__a:						Dict		    =					tiktoken.get_encoding("""gpt2"""    )
												__a:						str		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Optional[Any]		    =					tiktoken.get_encoding("""r50k_base"""    )
												__a:						Optional[int]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Optional[int]		    =					tiktoken.get_encoding("""gpt2"""    )
												__a:						Tuple		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






							@require_torch
							def 							__lowercase  (					self						:			int    ):






												"""simple docstring"""



												import torch

												__a:						List[str]		    =					torch.tensor([1.0]    )
												__a:						Union[str, Any]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						List[str]		    =					torch.tensor([2.0]    )
												__a:						Optional[Any]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						List[Any]		    =					torch.tensor([1.0]    )
												__a:						Dict		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






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






												"""simple docstring"""



												import spacy

												__a:						Union[str, Any]		    =					spacy.load("""en_core_web_sm"""    )
												__a:						int		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Dict		    =					spacy.load("""fr_core_news_sm"""    )
												__a:						int		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												__a:						Union[str, Any]		    =					spacy.load("""en_core_web_sm"""    )
												__a:						Optional[Any]		    =					mda(datasets.utils.py_utils.dumps(snake_case__    )    ).hexdigest()
												self.assertEqual(snake_case__						, snake_case__    )
												self.assertNotEqual(snake_case__						, snake_case__    )






@pytest.mark.integration
def     lowerCamelCase_    (	lowerCamelCase_ )     ->			List[Any]:


					'''simple docstring'''
					__a:						List[Any]		    =					tmp_path / """dir1"""
					__a:						Optional[int]		    =					tmp_path / """dir2"""
					dira.mkdir()
					dira.mkdir()
					__a:						List[Any]		    =					"""script.py"""
					__a:						str		    =					dedent(
					    """
    from datasets.fingerprint import Hasher
    def foo():
        pass
    print(Hasher.hash(foo))
    """ )
					__a:						Tuple		    =					dira / script_filename
					__a:						List[str]		    =					dira / script_filename
					with script_patha.open("""w""" ) as f:
										f.write(lowerCamelCase_ )
					with script_patha.open("""w""" ) as f:
										f.write(lowerCamelCase_ )
					__a:						Any		    =					subprocess.check_output(["""python""", str(lowerCamelCase_ )] )
					__a:						List[str]		    =					subprocess.check_output(["""python""", str(lowerCamelCase_ )] )
					assert fingerprinta == fingerprinta


def     lowerCamelCase_    (	)     ->			Optional[int]:


					'''simple docstring'''
					__a:						Any		    =					{"""a""": [0, 1, 2]}
					__a:						List[str]		    =					DatasetChild(InMemoryTable.from_pydict(lowerCamelCase_ ) )
					__a:						Any		    =					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     lowerCamelCase_    (	)     ->			str:


					'''simple docstring'''
					__a:						List[str]		    =					{"""a""": [0, 1, 2]}




					class    _snake_case  (						datasets.Dataset       ):






												@fingerprint_transform(inplace=snake_case__    )
												def 							__lowercase  (					self						:			Tuple						, snake_case__						:			List[str]    ):






																	"""simple docstring"""



																	return DummyDatasetChild(self.data						, fingerprint=snake_case__    )






					__a:						Dict		    =					DummyDatasetChild(InMemoryTable.from_pydict(lowerCamelCase_ ) ).func()




					class    _snake_case  (						datasets.Dataset       ):






												@fingerprint_transform(inplace=snake_case__						, version="""1.0.0"""    )
												def 							__lowercase  (					self						:			Union[str, Any]						, snake_case__						:			Dict    ):






																	"""simple docstring"""



																	return DummyDatasetChild(self.data						, fingerprint=snake_case__    )






					__a:						Union[str, Any]		    =					DummyDatasetChild(InMemoryTable.from_pydict(lowerCamelCase_ ) ).func()




					class    _snake_case  (						datasets.Dataset       ):






												@fingerprint_transform(inplace=snake_case__						, version="""2.0.0"""    )
												def 							__lowercase  (					self						:			List[str]						, snake_case__						:			Any    ):






																	"""simple docstring"""



																	return DummyDatasetChild(self.data						, fingerprint=snake_case__    )






					__a:						Optional[int]		    =					DummyDatasetChild(InMemoryTable.from_pydict(lowerCamelCase_ ) ).func()

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




def     lowerCamelCase_    (	)     ->			Tuple:


					'''simple docstring'''
					# AttributeError: module 'dill._dill' has no attribute 'stack'
					__a:						Optional[Any]		    =					Hasher()
					hasher.update(lambda lowerCamelCase_ : x )


"""simple docstring"""
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 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, logging


lowercase		:						Tuple =					logging.get_logger(__name__)




class    _snake_case  (						_lowercase       ):
							SCREAMING_SNAKE_CASE		     =						['''pixel_values''']






							def __init__(					self						:			Union[str, Any]						, snake_case__						:			bool = True						, snake_case__						:			Optional[Dict[str, int]] = None						, snake_case__						:			PILImageResampling = PILImageResampling.BILINEAR						, snake_case__						:			bool = True						, snake_case__						:			Union[int, float] = 1 / 2_5_5						, snake_case__						:			bool = True						, snake_case__						:			Optional[Union[float, List[float]]] = None						, snake_case__						:			Optional[Union[float, List[float]]] = None						, **snake_case__						:			Optional[int]						, ):






												"""simple docstring"""



												super().__init__(**snake_case__    )
												__a:						Dict		    =					size if size is not None else {"""height""": 2_2_4, """width""": 2_2_4}
												__a:						Optional[Any]		    =					get_size_dict(snake_case__    )
												__a:						Union[str, Any]		    =					do_resize
												__a:						str		    =					do_rescale
												__a:						Tuple		    =					do_normalize
												__a:						Dict		    =					size
												__a:						str		    =					resample
												__a:						Any		    =					rescale_factor
												__a:						Optional[int]		    =					image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
												__a:						int		    =					image_std if image_std is not None else IMAGENET_STANDARD_STD






							def 							__lowercase  (					self						:			Optional[Any]						, snake_case__						:			np.ndarray						, snake_case__						:			Dict[str, int]						, snake_case__						:			PILImageResampling = PILImageResampling.BILINEAR						, snake_case__						:			Optional[Union[str, ChannelDimension]] = None						, **snake_case__						:			List[str]						, ):






												"""simple docstring"""



												__a:						int		    =					get_size_dict(snake_case__    )
												if "height" not in size or "width" not in size:
																	raise ValueError(f"""The `size` dictionary must contain the keys `height` and `width`. Got {size.keys()}"""    )
												return resize(
												    snake_case__						, size=(size["""height"""], size["""width"""])						, resample=snake_case__						, data_format=snake_case__						, **snake_case__    )






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






												"""simple docstring"""



												return rescale(snake_case__						, scale=snake_case__						, data_format=snake_case__						, **snake_case__    )






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






												"""simple docstring"""



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






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






												"""simple docstring"""



												__a:						Any		    =					do_resize if do_resize is not None else self.do_resize
												__a:						Any		    =					do_rescale if do_rescale is not None else self.do_rescale
												__a:						int		    =					do_normalize if do_normalize is not None else self.do_normalize
												__a:						Any		    =					resample if resample is not None else self.resample
												__a:						Any		    =					rescale_factor if rescale_factor is not None else self.rescale_factor
												__a:						Dict		    =					image_mean if image_mean is not None else self.image_mean
												__a:						List[str]		    =					image_std if image_std is not None else self.image_std

												__a:						int		    =					size if size is not None else self.size
												__a:						Any		    =					get_size_dict(snake_case__    )

												__a:						List[str]		    =					make_list_of_images(snake_case__    )

												if not valid_images(snake_case__    ):
																	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:
																	raise ValueError("""Size must be specified if do_resize is True."""    )

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

												# All transformations expect numpy arrays.
												__a:						str		    =					[to_numpy_array(snake_case__    ) for image in images]

												if do_resize:
																	__a:						Dict		    =					[self.resize(image=snake_case__						, size=snake_case__						, resample=snake_case__    ) for image in images]

												if do_rescale:
																	__a:						str		    =					[self.rescale(image=snake_case__						, scale=snake_case__    ) for image in images]

												if do_normalize:
																	__a:						Dict		    =					[self.normalize(image=snake_case__						, mean=snake_case__						, std=snake_case__    ) for image in images]

												__a:						int		    =					[to_channel_dimension_format(snake_case__						, snake_case__    ) for image in images]

												__a:						str		    =					{"""pixel_values""": images}
												return BatchFeature(data=snake_case__						, tensor_type=snake_case__    )
