





'''simple docstring'''







import enum
import os
from hashlib import shaaaa
from typing import Optional

from .. import config
from .logging import get_logger


_lowercase       						=			get_logger(__name__)
class 			_lowercase						(       enum.Enum					):
     _UpperCAmelCase										=					'all_checks'
     _UpperCAmelCase										=					'basic_checks'
     _UpperCAmelCase										=					'no_checks'




class 			_lowercase						(       __a					):
     pass




class 			_lowercase						(       __a					):
     pass




class 			_lowercase						(       __a					):
     pass




class 			_lowercase						(       __a					):
     pass




def    __UpperCamelCase	(	a    : List[str]					,   a    : Optional[Any]					,   a    : Union[str, Any]=None     ) ->List[Any]:






 if expected_checksums is None:
  logger.info('''Unable to verify checksums.'''     )
  return
 if len(set(a     ) - set(a     )     ) > 0:
  raise ExpectedMoreDownloadedFiles(str(set(a     ) - set(a     )     )     )
 if len(set(a     ) - set(a     )     ) > 0:
  raise UnexpectedDownloadedFile(str(set(a     ) - set(a     )     )     )
 snake_case				=			[url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
 snake_case				=			''' for ''' + verification_name if verification_name is not None else ''''''
 if len(a     ) > 0:
  raise NonMatchingChecksumError(
      f"""Checksums didn't match{for_verification_name}:\n"""
      f"""{bad_urls}\n"""
      '''Set `verification_mode=\'no_checks\'` to skip checksums verification and ignore this error'''     )
 logger.info('''All the checksums matched successfully''' + for_verification_name     )
class 			_lowercase						(       __a					):
     pass




class 			_lowercase						(       __a					):
     pass




class 			_lowercase						(       __a					):
     pass




class 			_lowercase						(       __a					):
     pass




def    __UpperCamelCase	(	a    : int					,   a    : Union[str, Any]     ) ->Optional[int]:






 if expected_splits is None:
  logger.info('''Unable to verify splits sizes.'''     )
  return
 if len(set(a     ) - set(a     )     ) > 0:
  raise ExpectedMoreSplits(str(set(a     ) - set(a     )     )     )
 if len(set(a     ) - set(a     )     ) > 0:
  raise UnexpectedSplits(str(set(a     ) - set(a     )     )     )
 snake_case				=			[
     {'''expected''': expected_splits[name], '''recorded''': recorded_splits[name]}
     for name in expected_splits
     if expected_splits[name].num_examples != recorded_splits[name].num_examples
 ]
 if len(a     ) > 0:
  raise NonMatchingSplitsSizesError(str(a     )     )
 logger.info('''All the splits matched successfully.'''     )

def    __UpperCamelCase	(	a    : Optional[int]					,   a    : Union[str, Any] = True     ) ->dict:






 if record_checksum:
  snake_case				=			shaaaa()
  with open(a					,   '''rb'''     ) as f:
   for chunk in iter(lambda: f.read(1 << 20     )					,   b''''''     ):
    m.update(a     )
   snake_case				=			m.hexdigest()
 else:
  snake_case				=			None
 return {"num_bytes": os.path.getsize(a     ), "checksum": checksum}






def    __UpperCamelCase	(	a    : Optional[Any]     ) ->Union[str, Any]:






 if dataset_size and config.IN_MEMORY_MAX_SIZE:
  return dataset_size < config.IN_MEMORY_MAX_SIZE
 else:
  return False








'''simple docstring'''







from ..utils import DummyObject, requires_backends
class 			_lowercase						(       metaclass=__a					):
     _UpperCAmelCase										=					['''transformers''', '''torch''', '''note_seq''']







     def __init__( self    ,   *A__    ,   **A__    ) ->	Union[str, Any]:
      requires_backends(self    ,   ['''transformers''', '''torch''', '''note_seq''']    )







     @classmethod
     def     UpperCamelCase			( cls    ,   *A__    ,   **A__    ) ->	Optional[Any]:
      requires_backends(cls    ,   ['''transformers''', '''torch''', '''note_seq''']    )







     @classmethod
     def     UpperCamelCase			( cls    ,   *A__    ,   **A__    ) ->	Any:
      requires_backends(cls    ,   ['''transformers''', '''torch''', '''note_seq''']    )

