





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

from .. import config
from .logging import get_logger


__lowerCamelCase			:	Dict					    =	get_logger(__name__)



class    A__  (			enum.Enum     ):
      _UpperCAmelCase      :Tuple		       =  'all_checks'
      _UpperCAmelCase      :Any		       =  'basic_checks'
      _UpperCAmelCase      :int		       =  'no_checks'



class    A__  (			__snake_case     ):
      pass



class    A__  (			__snake_case     ):
      pass



class    A__  (			__snake_case     ):
      pass



class    A__  (			__snake_case     ):
      pass



def 						A_							(	_lowerCAmelCase				,  _lowerCAmelCase				,  _lowerCAmelCase=None	)		->					Dict:
 if expected_checksums is None:
  logger.info("Unable to verify checksums."	)
  return
 if len(set(_lowerCAmelCase	) - set(_lowerCAmelCase	)	) > 0:
  raise ExpectedMoreDownloadedFiles(str(set(_lowerCAmelCase	) - set(_lowerCAmelCase	)	)	)
 if len(set(_lowerCAmelCase	) - set(_lowerCAmelCase	)	) > 0:
  raise UnexpectedDownloadedFile(str(set(_lowerCAmelCase	) - set(_lowerCAmelCase	)	)	)
 UpperCamelCase      :   Tuple			      =  [url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
 UpperCamelCase      :   Union[str, Any]			      =  " for " + verification_name if verification_name is not None else ""
 if len(_lowerCAmelCase	) > 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    A__  (			__snake_case     ):
      pass



class    A__  (			__snake_case     ):
      pass



class    A__  (			__snake_case     ):
      pass



class    A__  (			__snake_case     ):
      pass



def 						A_							(	_lowerCAmelCase				,  _lowerCAmelCase	)		->					str:
 if expected_splits is None:
  logger.info("Unable to verify splits sizes."	)
  return
 if len(set(_lowerCAmelCase	) - set(_lowerCAmelCase	)	) > 0:
  raise ExpectedMoreSplits(str(set(_lowerCAmelCase	) - set(_lowerCAmelCase	)	)	)
 if len(set(_lowerCAmelCase	) - set(_lowerCAmelCase	)	) > 0:
  raise UnexpectedSplits(str(set(_lowerCAmelCase	) - set(_lowerCAmelCase	)	)	)
 UpperCamelCase      :   List[str]			      =  [
     {"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(_lowerCAmelCase	) > 0:
  raise NonMatchingSplitsSizesError(str(_lowerCAmelCase	)	)
 logger.info("All the splits matched successfully."	)



def 						A_							(	_lowerCAmelCase				,  _lowerCAmelCase = True	)		->					dict:
 if record_checksum:
  UpperCamelCase      :   str			      =  shaaaa()
  with open(_lowerCAmelCase				,  "rb"	) as f:
   for chunk in iter(lambda: f.read(1 << 20	)				,  b""	):
    m.update(_lowerCAmelCase	)
   UpperCamelCase      :   str			      =  m.hexdigest()
 else:
  UpperCamelCase      :   Union[str, Any]			      =  None
 return {"num_bytes": os.path.getsize(_lowerCAmelCase	), "checksum": checksum}



def 						A_							(	_lowerCAmelCase	)		->					Optional[Any]:
 if dataset_size and config.IN_MEMORY_MAX_SIZE:
  return dataset_size < config.IN_MEMORY_MAX_SIZE
 else:
  return False







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


__lowerCamelCase			:	List[Any]					    =	{
    """configuration_chinese_clip""": [
        """CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """ChineseCLIPConfig""",
        """ChineseCLIPOnnxConfig""",
        """ChineseCLIPTextConfig""",
        """ChineseCLIPVisionConfig""",
    ],
    """processing_chinese_clip""": ["""ChineseCLIPProcessor"""],
}

try:
    if not is_vision_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCamelCase			:	Tuple					    =	["""ChineseCLIPFeatureExtractor"""]
    __lowerCamelCase			:	List[str]					    =	["""ChineseCLIPImageProcessor"""]

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCamelCase			:	str					    =	[
        """CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """ChineseCLIPModel""",
        """ChineseCLIPPreTrainedModel""",
        """ChineseCLIPTextModel""",
        """ChineseCLIPVisionModel""",
    ]

if TYPE_CHECKING:
    from .configuration_chinese_clip import (
        CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
        ChineseCLIPConfig,
        ChineseCLIPOnnxConfig,
        ChineseCLIPTextConfig,
        ChineseCLIPVisionConfig,
    )
    from .processing_chinese_clip import ChineseCLIPProcessor

    try:
        if not is_vision_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .feature_extraction_chinese_clip import ChineseCLIPFeatureExtractor, ChineseCLIPImageProcessor

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_chinese_clip import (
            CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
            ChineseCLIPModel,
            ChineseCLIPPreTrainedModel,
            ChineseCLIPTextModel,
            ChineseCLIPVisionModel,
        )

else:
    import sys

    __lowerCamelCase			:	Any					    =	_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
