

'''simple docstring'''



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

from .. import config
from .logging import get_logger


UpperCAmelCase					:			Tuple       =	get_logger(__name__)







class 		lowerCAmelCase__  ( enum.Enum   ):



 """simple docstring"""



 lowerCAmelCase__       = "all_checks"
 lowerCAmelCase__       = "basic_checks"
 lowerCAmelCase__       = "no_checks"







class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""










class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""










class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""










class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""










def   a__			(    a__ ,       a__ ,       a__=None		):




     """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      = [url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
     __SCREAMING_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 		lowerCAmelCase__  ( a   ):



 """simple docstring"""










class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""










class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""










class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""










def   a__			(    a__ ,       a__		):




     """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      = [
         {"""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   a__			(    a__ ,       a__ = True		):




     """simple docstring"""


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







def   a__			(    a__		):




     """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 ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCAmelCase					:			Tuple       =	logging.get_logger(__name__)

UpperCAmelCase					:			Any       =	{'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'}







class 		lowerCAmelCase__  ( a   ):



 """simple docstring"""



 lowerCAmelCase__       = "ctrl"
 lowerCAmelCase__       = ["past_key_values"]
 lowerCAmelCase__       = {
     "max_position_embeddings": "n_positions",
     "hidden_size": "n_embd",
     "num_attention_heads": "n_head",
     "num_hidden_layers": "n_layer",
 }
 def __init__(						self   :			Tuple   ,				__SCREAMING_SNAKE_CASE   :			Tuple=246_534   ,				__SCREAMING_SNAKE_CASE   :			str=256   ,				__SCREAMING_SNAKE_CASE   :			Optional[Any]=1_280   ,				__SCREAMING_SNAKE_CASE   :			Dict=8_192   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=48   ,				__SCREAMING_SNAKE_CASE   :			Dict=16   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=0.1   ,				__SCREAMING_SNAKE_CASE   :			str=0.1   ,				__SCREAMING_SNAKE_CASE   :			Union[str, Any]=1E-6   ,				__SCREAMING_SNAKE_CASE   :			Tuple=0.02   ,				__SCREAMING_SNAKE_CASE   :			Tuple=True   ,				**__SCREAMING_SNAKE_CASE   :			Union[str, Any]   ,				)    ->					Tuple:


      """simple docstring"""




      __SCREAMING_SNAKE_CASE      = vocab_size
      __SCREAMING_SNAKE_CASE      = n_positions
      __SCREAMING_SNAKE_CASE      = n_embd
      __SCREAMING_SNAKE_CASE      = n_layer
      __SCREAMING_SNAKE_CASE      = n_head
      __SCREAMING_SNAKE_CASE      = dff
      __SCREAMING_SNAKE_CASE      = resid_pdrop
      __SCREAMING_SNAKE_CASE      = embd_pdrop
      __SCREAMING_SNAKE_CASE      = layer_norm_epsilon
      __SCREAMING_SNAKE_CASE      = initializer_range

      __SCREAMING_SNAKE_CASE      = use_cache

      super().__init__(**__SCREAMING_SNAKE_CASE     )






