




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 (
    get_resize_output_image_size,
    normalize,
    pad,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    get_image_size,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging
from ...utils.import_utils import is_vision_available


__SCREAMING_SNAKE_CASE    :   Tuple       =logging.get_logger(__name__)


if is_vision_available():
      import PIL






class 			A			(		_lowerCAmelCase		):
     """simple docstring"""

     _snake_case:	Dict     =["pixel_values"]




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

           lowerCamelCase__        =				size if size is not None else {'height': 2_5_6_0, 'width': 1_9_2_0}
           if isinstance(A__	,  (tuple, list)			):
                 # The previous feature extractor size parameter was in (width, height) format
                 lowerCamelCase__        =				size[::-1]
           lowerCamelCase__        =				get_size_dict(A__			)

           lowerCamelCase__        =				do_resize
           lowerCamelCase__        =				size
           lowerCamelCase__        =				resample
           lowerCamelCase__        =				do_thumbnail
           lowerCamelCase__        =				do_align_long_axis
           lowerCamelCase__        =				do_pad
           lowerCamelCase__        =				do_rescale
           lowerCamelCase__        =				rescale_factor
           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




     def  __snake_case   (    self  :   str	,  A__  :   np.ndarray	,  A__  :   Dict[str, int]	,  A__  :   Optional[Union[str, ChannelDimension]] = None			)				->       np.ndarray:
           lowerCamelCase__  ,		lowerCamelCase__        =				get_image_size(A__			)
           lowerCamelCase__  ,		lowerCamelCase__        =				size['height'], size['width']

           if (output_width < output_height and input_width > input_height) or (
               output_width > output_height and input_width < input_height
           ):
                 lowerCamelCase__        =				np.rotaa(A__	,  3			)

           if data_format is not None:
                 lowerCamelCase__        =				to_channel_dimension_format(A__	,  A__			)

           return image




     def  __snake_case   (    self  :   Tuple	,  A__  :   np.ndarray	,  A__  :   Dict[str, int]	,  A__  :   bool = False	,  A__  :   Optional[Union[str, ChannelDimension]] = None	,  )				->       np.ndarray:
           lowerCamelCase__  ,		lowerCamelCase__        =				size['height'], size['width']
           lowerCamelCase__  ,		lowerCamelCase__        =				get_image_size(A__			)

           lowerCamelCase__        =				output_width - input_width
           lowerCamelCase__        =				output_height - input_height

           if random_padding:
                 lowerCamelCase__        =				np.random.randint(low=0	,  high=delta_height + 1			)
                 lowerCamelCase__        =				np.random.randint(low=0	,  high=delta_width + 1			)
           else:
                 lowerCamelCase__        =				delta_height // 2
                 lowerCamelCase__        =				delta_width // 2

           lowerCamelCase__        =				delta_height - pad_top
           lowerCamelCase__        =				delta_width - pad_left

           lowerCamelCase__        =				((pad_top, pad_bottom), (pad_left, pad_right))
           return pad(A__	,  A__	,  data_format=A__			)




     def  __snake_case   (    self  :   int	,  *A__  :   Tuple	,  **A__  :   Dict			)				->       List[Any]:
           logger.info('pad is deprecated and will be removed in version 4.27. Please use pad_image instead.'			)
           return self.pad_image(*A__	,  **A__			)




     def  __snake_case   (    self  :   Any	,  A__  :   np.ndarray	,  A__  :   Dict[str, int]	,  A__  :   PILImageResampling = PILImageResampling.BICUBIC	,  A__  :   Optional[Union[str, ChannelDimension]] = None	,  **A__  :   Any	,  )				->       np.ndarray:
           lowerCamelCase__  ,		lowerCamelCase__        =				get_image_size(A__			)
           lowerCamelCase__  ,		lowerCamelCase__        =				size['height'], size['width']

           # We always resize to the smallest of either the input or output size.
           lowerCamelCase__        =				min(A__	,  A__			)
           lowerCamelCase__        =				min(A__	,  A__			)

           if height == input_height and width == input_width:
                 return image

           if input_height > input_width:
                 lowerCamelCase__        =				int(input_width * height / input_height			)
           elif input_width > input_height:
                 lowerCamelCase__        =				int(input_height * width / input_width			)

           return resize(
               A__	,  size=(height, width)	,  resample=A__	,  reducing_gap=2.0	,  data_format=A__	,  **A__			)




     def  __snake_case   (    self  :   List[str]	,  A__  :   np.ndarray	,  A__  :   Dict[str, int]	,  A__  :   PILImageResampling = PILImageResampling.BICUBIC	,  A__  :   Optional[Union[str, ChannelDimension]] = None	,  **A__  :   Any	,  )				->       np.ndarray:
           lowerCamelCase__        =				get_size_dict(A__			)
           lowerCamelCase__        =				min(size['height']	,  size['width']			)
           lowerCamelCase__        =				get_resize_output_image_size(A__	,  size=A__	,  default_to_square=A__			)
           lowerCamelCase__        =				resize(A__	,  size=A__	,  resample=A__	,  data_format=A__	,  **A__			)
           return resized_image




     def  __snake_case   (    self  :   Optional[int]	,  A__  :   np.ndarray	,  A__  :   Union[int, float]	,  A__  :   Optional[Union[str, ChannelDimension]] = None	,  **A__  :   Optional[int]	,  )				->       Tuple:
           return rescale(A__	,  scale=A__	,  data_format=A__	,  **A__			)




     def  __snake_case   (    self  :   Any	,  A__  :   np.ndarray	,  A__  :   Union[float, List[float]]	,  A__  :   Union[float, List[float]]	,  A__  :   Optional[Union[str, ChannelDimension]] = None	,  **A__  :   Union[str, Any]	,  )				->       np.ndarray:
           return normalize(A__	,  mean=A__	,  std=A__	,  data_format=A__	,  **A__			)




     def  __snake_case   (    self  :   Union[str, Any]	,  A__  :   ImageInput	,  A__  :   bool = None	,  A__  :   Dict[str, int] = None	,  A__  :   PILImageResampling = None	,  A__  :   bool = None	,  A__  :   bool = None	,  A__  :   bool = None	,  A__  :   bool = False	,  A__  :   bool = None	,  A__  :   float = None	,  A__  :   bool = None	,  A__  :   Optional[Union[float, List[float]]] = None	,  A__  :   Optional[Union[float, List[float]]] = None	,  A__  :   Optional[Union[str, TensorType]] = None	,  A__  :   Optional[ChannelDimension] = ChannelDimension.FIRST	,  **A__  :   Any	,  )				->       PIL.Image.Image:
           lowerCamelCase__        =				do_resize if do_resize is not None else self.do_resize
           lowerCamelCase__        =				size if size is not None else self.size
           if isinstance(A__	,  (tuple, list)			):
                 # Previous feature extractor had size in (width, height) format
                 lowerCamelCase__        =				size[::-1]
           lowerCamelCase__        =				get_size_dict(A__			)
           lowerCamelCase__        =				resample if resample is not None else self.resample
           lowerCamelCase__        =				do_thumbnail if do_thumbnail is not None else self.do_thumbnail
           lowerCamelCase__        =				do_align_long_axis if do_align_long_axis is not None else self.do_align_long_axis
           lowerCamelCase__        =				do_pad if do_pad is not None else self.do_pad
           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__        =				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__        =				make_list_of_images(A__			)

           if not valid_images(A__			):
                 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.'			)

           if do_pad and size is None:
                 raise ValueError('Size must be specified if do_pad 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(A__			) for image in images]

           if do_align_long_axis:
                 lowerCamelCase__        =				[self.align_long_axis(A__	,  size=A__			) for image in images]

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

           if do_thumbnail:
                 lowerCamelCase__        =				[self.thumbnail(image=A__	,  size=A__			) for image in images]

           if do_pad:
                 lowerCamelCase__        =				[self.pad_image(image=A__	,  size=A__	,  random_padding=A__			) for image in images]

           if do_rescale:
                 lowerCamelCase__        =				[self.rescale(image=A__	,  scale=A__			) for image in images]

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

           lowerCamelCase__        =				[to_channel_dimension_format(A__	,  A__			) for image in images]

           lowerCamelCase__        =				{'pixel_values': images}
           return BatchFeature(data=A__	,  tensor_type=A__			)





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

     def __init__(    self  :   Optional[int]	,  A__  :   Optional[Any]			)				->       Dict:
           lowerCamelCase__        =				foo




     def __call__(    self  :   Dict			)				->       Optional[int]:
           return self.foo






class 			A			(		datasets.Dataset		):
     """simple docstring"""

     @fingerprint_transform(inplace=A__			)
     def  __snake_case   (    self  :   Optional[Any]	,  A__  :   Tuple	,  *A__  :   List[str]	,  **A__  :   List[Any]			)				->       Dict:
           return DatasetChild(self.data	,  fingerprint=A__			)




     @fingerprint_transform(inplace=A__			)
     def  __snake_case   (    self  :   Any	,  A__  :   Optional[int]	,  *A__  :   List[str]	,  **A__  :   Union[str, Any]			)				->       List[Any]:
           return DatasetChild(self.data	,  fingerprint=A__			)






class 			A			:
     """simple docstring"""

     def __init__(    self  :   List[Any]	,  A__  :   Tuple			)				->       List[Any]:
           lowerCamelCase__        =				callable




     def __call__(    self  :   Dict	,  *A__  :   Dict	,  **A__  :   List[str]			)				->       List[str]:
           if self.callable is not None:
                 return self.callable(*A__	,  **A__			)




     def __getstate__(    self  :   Optional[Any]			)				->       Union[str, Any]:
           raise pickle.PicklingError()






class 			A			(		_lowerCAmelCase		):
     """simple docstring"""

     @require_transformers
     @pytest.mark.integration
     def  __snake_case   (    self  :   str			)				->       int:
           from transformers import AutoTokenizer

           def encode(A__  :   List[Any]			):
                 return tokenizer(A__			)

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




     @require_transformers
     @pytest.mark.integration
     def  __snake_case   (    self  :   int			)				->       List[str]:
           from transformers import AutoTokenizer

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




     @require_regex
     def  __snake_case   (    self  :   Dict			)				->       Dict:
           import regex

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






class 			A			(		_lowerCAmelCase		):
     """simple docstring"""

     def  __snake_case   (    self  :   Tuple			)				->       List[Any]:
           def func():
                 return foo

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




     def  __snake_case   (    self  :   Optional[int]			)				->       str:
           def func():
                 pass

           lowerCamelCase__        =				mda(datasets.utils.py_utils.dumps(A__			)			).hexdigest()

           def func():
                 pass

           lowerCamelCase__        =				mda(datasets.utils.py_utils.dumps(A__			)			).hexdigest()
           self.assertEqual(A__	,  A__			)




     def  __snake_case   (    self  :   List[Any]			)				->       Optional[Any]:
           lowerCamelCase__        =				mda(datasets.utils.py_utils.dumps(Foo([0]			)			)			).hexdigest()
           lowerCamelCase__        =				mda(datasets.utils.py_utils.dumps(Foo([1]			)			)			).hexdigest()
           lowerCamelCase__        =				mda(datasets.utils.py_utils.dumps(Foo([0]			)			)			).hexdigest()
           self.assertEqual(A__	,  A__			)
           self.assertNotEqual(A__	,  A__			)




     def  __snake_case   (    self  :   Union[str, Any]			)				->       str:
           lowerCamelCase__        =				mda(datasets.utils.py_utils.dumps(Foo([0]			).__call__			)			).hexdigest()
           lowerCamelCase__        =				mda(datasets.utils.py_utils.dumps(Foo([1]			).__call__			)			).hexdigest()
           lowerCamelCase__        =				mda(datasets.utils.py_utils.dumps(Foo([0]			).__call__			)			).hexdigest()
           self.assertEqual(A__	,  A__			)
           self.assertNotEqual(A__	,  A__			)




     def  __snake_case   (    self  :   Optional[Any]			)				->       Optional[Any]:
           lowerCamelCase__        =				(
               '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(*A__  :   Any			):
                 if hasattr(args[-3]	,  'encode'			):
                       lowerCamelCase__        =				list(A__			)
                       lowerCamelCase__        =				args[-3].encode()  # co_lnotab
                       lowerCamelCase__        =				args[-1_0].encode()  # co_code
                 if hasattr(A__	,  'co_posonlyargcount'			):
                       if len(A__			) == 1_6:
                             return CodeType(*A__			)
                       elif len(A__			) == 1_5:
                             return CodeType(args[0]	,  0	,  *args[1:]			)
                       return CodeType(args[0]	,  0	,  0	,  *args[1:]			)
                 elif hasattr(A__	,  'co_kwonlyargcount'			):
                       if len(A__			) == 1_6:
                             return CodeType(args[0]	,  *args[2:]			)
                       elif len(A__			) == 1_5:
                             return CodeType(*A__			)
                       return CodeType(args[0]	,  0	,  *args[1:]			)
                 if len(A__			) == 1_6:
                       return CodeType(args[0]	,  *args[3:]			)
                 elif len(A__			) == 1_5:
                       return CodeType(args[0]	,  *args[2:]			)
                 return CodeType(*A__			)

           def create_ipython_func(A__  :   Any	,  A__  :   Tuple			):
                 def func():
                       return returned_obj

                 lowerCamelCase__        =				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'			):
                       lowerCamelCase__        =				_create_code_pyaa(
                           *[getattr(A__	,  A__			) if k != 'co_filename' else co_filename for k in code_args_pyaa]			)
                 else:
                       lowerCamelCase__        =				code.replace(co_filename=A__			)
                 return FunctionType(A__	,  func.__globals__	,  func.__name__	,  func.__defaults__	,  func.__closure__			)

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

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




     def  __snake_case   (    self  :   Optional[Any]			)				->       List[Any]:
           lowerCamelCase__  ,		lowerCamelCase__        =				[0], [1]

           def func():
                 return foo, bar

           lowerCamelCase__        =				'__main__'

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

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

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






class 			A			(		_lowerCAmelCase		):
     """simple docstring"""

     def  __snake_case   (    self  :   str			)				->       List[str]:
           lowerCamelCase__        =				Hasher.hash('hello'			)
           lowerCamelCase__        =				Hasher.hash('hello'			)
           lowerCamelCase__        =				Hasher.hash('there'			)
           self.assertEqual(A__	,  A__			)
           self.assertNotEqual(A__	,  A__			)




     def  __snake_case   (    self  :   List[str]			)				->       Optional[Any]:
           lowerCamelCase__        =				Hasher.hash(Foo('hello'			)			)
           lowerCamelCase__        =				Hasher.hash(Foo('hello'			)			)
           lowerCamelCase__        =				Hasher.hash(Foo('there'			)			)
           self.assertEqual(A__	,  A__			)
           self.assertNotEqual(A__	,  A__			)




     def  __snake_case   (    self  :   Tuple			)				->       str:
           lowerCamelCase__        =				Hasher()
           for x in ["hello", Foo('hello'			)]:
                 hasher.update(A__			)
           lowerCamelCase__        =				hasher.hexdigest()
           lowerCamelCase__        =				Hasher()
           for x in ["hello", Foo('hello'			)]:
                 hasher.update(A__			)
           lowerCamelCase__        =				hasher.hexdigest()
           lowerCamelCase__        =				Hasher()
           for x in ["there", Foo('there'			)]:
                 hasher.update(A__			)
           lowerCamelCase__        =				hasher.hexdigest()
           self.assertEqual(A__	,  A__			)
           self.assertNotEqual(A__	,  A__			)




     def  __snake_case   (    self  :   Any			)				->       Tuple:
           with self.assertRaises(pickle.PicklingError			):
                 Hasher.hash(UnpicklableCallable(Foo('hello'			)			)			)




     def  __snake_case   (    self  :   Optional[int]			)				->       Optional[Any]:
           lowerCamelCase__        =				'abc'
           lowerCamelCase__        =				[string, string]  # two strings have the same ids
           lowerCamelCase__        =				[string, string]
           lowerCamelCase__        =				json.loads(F"""[\"{string}\", \"{string}\"]"""			)  # two strings have different ids
           self.assertIs(obja[0]	,  A__			)
           self.assertIs(obja[0]	,  obja[1]			)
           self.assertIs(obja[0]	,  A__			)
           self.assertIs(obja[0]	,  obja[1]			)
           self.assertIsNot(obja[0]	,  A__			)
           self.assertIsNot(obja[0]	,  obja[1]			)
           lowerCamelCase__        =				Hasher.hash(A__			)
           lowerCamelCase__        =				Hasher.hash(A__			)
           lowerCamelCase__        =				Hasher.hash(A__			)
           self.assertEqual(A__	,  A__			)
           self.assertEqual(A__	,  A__			)




     @require_tiktoken
     def  __snake_case   (    self  :   Union[str, Any]			)				->       str:
           import tiktoken

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




     @require_torch
     def  __snake_case   (    self  :   Optional[Any]			)				->       List[Any]:
           import torch

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




     @require_spacy
     @require_spacy_model('en_core_web_sm'			)
     @require_spacy_model('fr_core_news_sm'			)
     @pytest.mark.integration
     def  __snake_case   (    self  :   Tuple			)				->       List[str]:
           import spacy

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

@pytest.mark.integration
def 			lowerCAmelCase_			(  lowerCamelCase:       Path						)					->			Optional[int]:


      '''simple docstring'''




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

def 			lowerCAmelCase_			(  )					->			int:


      '''simple docstring'''




      lowerCamelCase__        =				{'a': [0, 1, 2]}
      lowerCamelCase__        =				DatasetChild(InMemoryTable.from_pydict(lowerCamelCase						)						)
      lowerCamelCase__        =				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_			(  )					->			Union[str, Any]:


      '''simple docstring'''




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






      class 			A			(		datasets.Dataset		):
           """simple docstring"""

           @fingerprint_transform(inplace=A__			)
           def  __snake_case   (    self  :   Any	,  A__  :   Union[str, Any]			)				->       List[Any]:
                 return DummyDatasetChild(self.data	,  fingerprint=A__			)
      lowerCamelCase__        =				DummyDatasetChild(InMemoryTable.from_pydict(lowerCamelCase						)						).func()






      class 			A			(		datasets.Dataset		):
           """simple docstring"""

           @fingerprint_transform(inplace=A__	,  version='1.0.0'			)
           def  __snake_case   (    self  :   str	,  A__  :   List[Any]			)				->       List[str]:
                 return DummyDatasetChild(self.data	,  fingerprint=A__			)
      lowerCamelCase__        =				DummyDatasetChild(InMemoryTable.from_pydict(lowerCamelCase						)						).func()






      class 			A			(		datasets.Dataset		):
           """simple docstring"""

           @fingerprint_transform(inplace=A__	,  version='2.0.0'			)
           def  __snake_case   (    self  :   List[str]	,  A__  :   int			)				->       int:
                 return DummyDatasetChild(self.data	,  fingerprint=A__			)
      lowerCamelCase__        =				DummyDatasetChild(InMemoryTable.from_pydict(lowerCamelCase						)						).func()

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


def 			lowerCAmelCase_			(  )					->			int:


      '''simple docstring'''




      lowerCamelCase__        =				Hasher()
      hasher.update(lambda lowerCamelCase						: x						)