





# Lint as: python3

import hashlib
from typing import Union



def _a       (			lowerCamelCase:     Union[str, int, bytes]				)			->		bytes:







      '''simple docstring'''






      if isinstance(lowerCamelCase      ,       lowerCamelCase				):
            # Data already in bytes, returns as it as
            return hash_data
      elif isinstance(lowerCamelCase      ,       lowerCamelCase				):
            # We keep the data as it as for it ot be later encoded to UTF-8
            # However replace `\\` with `/` for Windows compatibility
            __A      =       hash_data.replace('''\\'''      ,       '''/'''				)
      elif isinstance(lowerCamelCase      ,       lowerCamelCase				):
            __A      =       str(lowerCamelCase				)
      else:
            # If data is not of the required type, raise error
            raise InvalidKeyError(lowerCamelCase				)

      return hash_data.encode('''utf-8'''				)





class A_      (    _lowerCamelCase     ):




   def __init__(self			:str					,     _UpperCamelCase			:Tuple				)->      List[Any]:
         __A      =       '''\nFAILURE TO GENERATE DATASET: Invalid key type detected'''
         __A      =       f"""\nFound Key {hash_data} of type {type(_UpperCamelCase				)}"""
         __A      =       '''\nKeys should be either str, int or bytes type'''
         super().__init__(f"""{self.prefix}{self.err_msg}{self.suffix}"""				)





class A_      (    _lowerCamelCase     ):




   def __init__(self			:Dict					,     _UpperCamelCase			:Optional[int]					,     _UpperCamelCase			:List[Any]					,     _UpperCamelCase			:Union[str, Any]=""				)->      str:
         __A      =       key
         __A      =       duplicate_key_indices
         __A      =       fix_msg
         __A      =       '''Found multiple examples generated with the same key'''
         if len(_UpperCamelCase				) <= 20:
               __A      =       f"""\nThe examples at index {', '.join(_UpperCamelCase				)} have the key {key}"""
         else:
               __A      =       f"""\nThe examples at index {', '.join(duplicate_key_indices[:20]				)}... ({len(_UpperCamelCase				) - 20} more) have the key {key}"""
         __A      =       '''\n''' + fix_msg if fix_msg else ''''''
         super().__init__(f"""{self.prefix}{self.err_msg}{self.suffix}"""				)





class A_      :




   def __init__(self			:Dict					,     _UpperCamelCase			:str				)->      str:
         __A      =       hashlib.mda(_as_bytes(_UpperCamelCase				)				)






   def _lowerCAmelCase   (self			:int					,     _UpperCamelCase			:Union[str, int, bytes]				)->      int:
         __A      =       self._split_mda.copy()
         __A      =       _as_bytes(_UpperCamelCase				)
         mda.update(_UpperCamelCase				)
         # Convert to integer with hexadecimal conversion
         return int(mda.hexdigest()					,     16				)












from unittest.mock import patch

import datasets
from datasets import Dataset



def _a       (			)			->		Optional[Any]:







      '''simple docstring'''






      __A      =       Dataset.from_dict({'''col_1''': [3, 2, 0, 1]}				)

      with patch('''tqdm.auto.tqdm'''				) as mock_tqdm:
            datasets.disable_progress_bar()
            dset.map(lambda lowerCamelCase				: {"col_2": x["col_1"] + 1}				)
            mock_tqdm.assert_not_called()

            mock_tqdm.reset_mock()

            datasets.enable_progress_bar()
            dset.map(lambda lowerCamelCase				: {"col_2": x["col_1"] + 1}				)
            mock_tqdm.assert_called()





