



"""simple docstring"""

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

from .. import config
from .logging import get_logger


lowercase__    :  List[Any]							    =	get_logger(__name__)




class        _UpperCAmelCase       (			enum.Enum):
 _lowerCAmelCase   :			Optional[int]							=		"""all_checks"""
 _lowerCAmelCase   :			List[Any]							=		"""basic_checks"""
 _lowerCAmelCase   :			Optional[Any]							=		"""no_checks"""





class        _UpperCAmelCase       (			lowerCAmelCase__):
 pass





class        _UpperCAmelCase       (			lowerCAmelCase__):
 pass





class        _UpperCAmelCase       (			lowerCAmelCase__):
 pass





class        _UpperCAmelCase       (			lowerCAmelCase__):
 pass





def __lowercase			(							_a		,			_a		,			_a=None    ):
    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_ :     Any				=	[url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
    snake_case_ :     Optional[int]				=	''' 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        _UpperCAmelCase       (			lowerCAmelCase__):
 pass





class        _UpperCAmelCase       (			lowerCAmelCase__):
 pass





class        _UpperCAmelCase       (			lowerCAmelCase__):
 pass





class        _UpperCAmelCase       (			lowerCAmelCase__):
 pass





def __lowercase			(							_a		,			_a    ):
    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_ :     int				=	[
        {'''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 __lowercase			(							_a		,			_a = True    ):
    if record_checksum:
        snake_case_ :     int				=	shaaaa()
        with open(_a		,			'''rb'''    ) as f:
            for chunk in iter(lambda: f.read(1 << 20    )		,			b''''''    ):
                m.update(_a    )
            snake_case_ :     List[Any]				=	m.hexdigest()
    else:
        snake_case_ :     str				=	None
    return {"num_bytes": os.path.getsize(_a    ), "checksum": checksum}






def __lowercase			(							_a    ):
    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_torch_available


lowercase__    :  str							    =	{
    '''configuration_x_clip''': [
        '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''XCLIPConfig''',
        '''XCLIPTextConfig''',
        '''XCLIPVisionConfig''',
    ],
    '''processing_x_clip''': ['''XCLIPProcessor'''],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowercase__    :  Tuple							    =	[
         '''XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''XCLIPModel''',
         '''XCLIPPreTrainedModel''',
         '''XCLIPTextModel''',
         '''XCLIPVisionModel''',
     ]

if TYPE_CHECKING:
     from .configuration_x_clip import (
         XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
         XCLIPConfig,
         XCLIPTextConfig,
         XCLIPVisionConfig,
     )
     from .processing_x_clip import XCLIPProcessor

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_x_clip import (
              XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
              XCLIPModel,
              XCLIPPreTrainedModel,
              XCLIPTextModel,
              XCLIPVisionModel,
          )

else:
     import sys

     lowercase__    :  Tuple							    =	_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





