# Lint as: python3

import hashlib
from typing import Union






def       __lowerCamelCase		(						lowerCAmelCase__	):
       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
              lowerCAmelCase__     	=					hash_data.replace('\\'	,  '/'	)
       elif isinstance(lowerCAmelCase__	,  lowerCAmelCase__	):
              lowerCAmelCase__     	=					str(lowerCAmelCase__	)
       else:
              # If data is not of the required type, raise error
              raise InvalidKeyError(lowerCAmelCase__	)

       return hash_data.encode('utf-8'	)
class 				a_ (						SCREAMING_SNAKE_CASE						):






 '''simple docstring'''






 def __init__(			self					:  Any			,    lowercase__					:  Dict):







        '''simple docstring'''



        lowerCAmelCase__     	=					'\nFAILURE TO GENERATE DATASET: Invalid key type detected'
        lowerCAmelCase__     	=					F"""\nFound Key {hash_data} of type {type(lowercase__)}"""
        lowerCAmelCase__     	=					'\nKeys should be either str, int or bytes type'
        super().__init__(F"""{self.prefix}{self.err_msg}{self.suffix}""")






class 				a_ (						SCREAMING_SNAKE_CASE						):






 '''simple docstring'''






 def __init__(			self					:  Optional[int]			,    lowercase__					:  str			,    lowercase__					:  str			,    lowercase__					:  Union[str, Any]=""):







        '''simple docstring'''



        lowerCAmelCase__     	=					key
        lowerCAmelCase__     	=					duplicate_key_indices
        lowerCAmelCase__     	=					fix_msg
        lowerCAmelCase__     	=					'Found multiple examples generated with the same key'
        if len(lowercase__) <= 20:
               lowerCAmelCase__     	=					F"""\nThe examples at index {', '.join(lowercase__)} have the key {key}"""
        else:
               lowerCAmelCase__     	=					F"""\nThe examples at index {', '.join(duplicate_key_indices[:20])}... ({len(lowercase__) - 20} more) have the key {key}"""
        lowerCAmelCase__     	=					'\n' + fix_msg if fix_msg else ''
        super().__init__(F"""{self.prefix}{self.err_msg}{self.suffix}""")






class 				a_ :






 '''simple docstring'''






 def __init__(			self					:  Union[str, Any]			,    lowercase__					:  str):







        '''simple docstring'''



        lowerCAmelCase__     	=					hashlib.mda(_as_bytes(lowercase__))




 def 		__snake_case						(			self					:  Union[str, Any]			,    lowercase__					:  Union[str, int, bytes]):







        '''simple docstring'''



        lowerCAmelCase__     	=					self._split_mda.copy()
        lowerCAmelCase__     	=					_as_bytes(lowercase__)
        mda.update(lowercase__)
        # Convert to integer with hexadecimal conversion
        return int(mda.hexdigest()			,    16)

from ..utils import DummyObject, requires_backends
class 				a_ (						metaclass=SCREAMING_SNAKE_CASE						):






 '''simple docstring'''






 UpperCAmelCase_	 =					['tensorflow_text']




 def __init__(			self					:  Tuple			,    *lowercase__					:  str			,    **lowercase__					:  Union[str, Any]):







        '''simple docstring'''



        requires_backends(self			,    ['tensorflow_text'])
