



"""simple docstring"""

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

from .. import config
from .logging import get_logger


A_						:    Optional[int]				=      get_logger(__name__)
class     lowerCAmelCase__						(	enum.Enum ):


	'''simple docstring'''







	_SCREAMING_SNAKE_CASE	:		List[str]  						= '''all_checks'''
	_SCREAMING_SNAKE_CASE	:		Optional[Any]  						= '''basic_checks'''
	_SCREAMING_SNAKE_CASE	:		Optional[Any]  						= '''no_checks'''




class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''











class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''











class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''











class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''











def  __snake_case							(	__A      :						Optional[dict]							,		__A      :						dict							,		__A      :						Any=None     )     ->       Tuple:






				'''simple docstring'''
				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     )     )     )
				SCREAMING_SNAKE_CASE						:							Dict							=     [url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
				SCREAMING_SNAKE_CASE						:							Dict							=     ' 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     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''











class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''











class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''











class     lowerCAmelCase__						(	_lowerCamelCase ):


	'''simple docstring'''











def  __snake_case							(	__A      :						Optional[dict]							,		__A      :						dict     )     ->       Union[str, Any]:






				'''simple docstring'''
				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     )     )     )
				SCREAMING_SNAKE_CASE						:							List[Any]							=     [
				    {'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  __snake_case							(	__A      :						str							,		__A      :						bool = True     )     ->       dict:






				'''simple docstring'''
				if record_checksum:
								SCREAMING_SNAKE_CASE						:							int							=     shaaaa()
								with open(__A							,		'rb'     ) as f:
												for chunk in iter(lambda: f.read(1 << 20     )							,		B''     ):
																m.update(__A     )
												SCREAMING_SNAKE_CASE						:							Optional[int]							=     m.hexdigest()
				else:
								SCREAMING_SNAKE_CASE						:							str							=     None
				return {"num_bytes": os.path.getsize(__A     ), "checksum": checksum}







def  __snake_case							(	__A      :						Union[str, Any]     )     ->       Optional[Any]:






				'''simple docstring'''
				if dataset_size and config.IN_MEMORY_MAX_SIZE:
								return dataset_size < config.IN_MEMORY_MAX_SIZE
				else:
								return False










"""simple docstring"""

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


A_						:    Optional[int]				=      {
    'configuration_llama': ['LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LlamaConfig'],
}

try:
							if not is_sentencepiece_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A_						:    int				=      ['LlamaTokenizer']

try:
							if not is_tokenizers_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A_						:    List[str]				=      ['LlamaTokenizerFast']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A_						:    List[str]				=      [
							    'LlamaForCausalLM',
							    'LlamaModel',
							    'LlamaPreTrainedModel',
							    'LlamaForSequenceClassification',
							]


if TYPE_CHECKING:
							from .configuration_llama import LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP, LlamaConfig

							try:
														if not is_sentencepiece_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_llama import LlamaTokenizer

							try:
														if not is_tokenizers_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_llama_fast import LlamaTokenizerFast

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_llama import LlamaForCausalLM, LlamaForSequenceClassification, LlamaModel, LlamaPreTrainedModel


else:
							import sys

							A_						:    str				=      _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





