/usr/local/lib/python3.6/site-packages/transformers/models/auto/__pycache__
NameSizeModeActions
auto_factory.cpython-36.pyc258020644editdlrm
configuration_auto.cpython-36.pyc289760644editdlrm
dynamic.cpython-36.pyc71740644editdlrm
feature_extraction_auto.cpython-36.pyc136250644editdlrm
modeling_auto.cpython-36.pyc288280644editdlrm
modeling_flax_auto.cpython-36.pyc92070644editdlrm
modeling_tf_auto.cpython-36.pyc159800644editdlrm
processing_auto.cpython-36.pyc95950644editdlrm
tokenization_auto.cpython-36.pyc207540644editdlrm
__init__.cpython-36.pyc64320644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/transformers/models/auto/__pycache__/dynamic.cpython-36.pyc (7174B)
3 Egh& @sdZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z ddl m Z mZmZmZmZddlmZejeZdd Ze eejfd d d Zd dZddZde eejfeee e eejfeee e eefe e eefe eed ddZdS)z?Utilities to dynamically load model and tokenizer from the Hub.N)Path)DictOptionalUnion)HF_MODULES_CACHE TRANSFORMERS_DYNAMIC_MODULE_NAME cached_path hf_bucket_urlis_offline_mode)loggingcCsHttjkrdStjjttjtddttd}|jsD|jdS)z_ Creates the cache directory for modules with an init, and adds it to the Python path. NT)exist_okz __init__.py) rsyspathappendosmakedirsrexiststouch) init_pathrJ/usr/local/lib/python3.6/site-packages/transformers/models/auto/dynamic.pyinit_hf_modules&s   r)namecCsPttt|}|jjs&t|jtj|dd|d}|jsL|jdS)zF Creates a dynamic module in the cache directory for modules. T)r z __init__.pyN) rrrparentrcreate_dynamic_modulerrr)rZdynamic_module_pathrrrrr5s   rcCst|ddd}|j}WdQRXtjd|tjd}|tjd|tjd7}dd |D}tt|}g}x:|D]2}ytj|Wqnt k r|j |YqnXqnWt |d krt d d j |d dj |ddS)zi Check if the current Python environment contains all the libraries that are imported in a file. rzutf-8)encodingNz^\s*import\s+(\S+)\s*$)flagsz^\s*from\s+(\S+)\s+importcSs$g|]}|jds|jddqS).r) startswithsplit).0imprrr Psz!check_imports..rz\This modeling file requires the following packages that were not found in your environment: z, z. Run `pip install  `) openreadrefindall MULTILINElistset importlib import_module ImportErrorrlenjoin)filenamefcontentZimportsZmissing_packagesr#rrr check_importsDs   r6cCs$|jtjjd}tj|}t||S)zY Import a module on the cache directory for modules and extract a class from it. r)replacerrsepr.r/getattr) class_name module_pathmodulerrrget_class_in_modulebs r=F) pretrained_model_name_or_path module_filer: cache_dirforce_downloadresume_downloadproxiesuse_auth_tokenrevisionlocal_files_onlyc Ksdtr| rtjdd} t|}tjj|rBtjj||} d} n t|||dd} |j dtjj } yt | ||||| |d} Wn.t k rtj d|d |d YnXt| ttjj | }t|tt|}| dkr|}tj| ||nNt| j}|j d d g|jd }d j|d }||jsDtj| ||tjj||j d d }t||S)a* Extracts a class from a module file, present in the local folder or repository of a model. Calling this function will execute the code in the module file found locally or downloaded from the Hub. It should therefore only be called on trusted repos. Args: pretrained_model_name_or_path (`str` or `os.PathLike`): This can be either: - a string, the *model id* of a pretrained model configuration hosted inside a model repo on huggingface.co. Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a user or organization name, like `dbmdz/bert-base-german-cased`. - a path to a *directory* containing a configuration file saved using the [`~PreTrainedTokenizer.save_pretrained`] method, e.g., `./my_model_directory/`. module_file (`str`): The name of the module file containing the class to look for. class_name (`str`): The name of the class to import in the module. cache_dir (`str` or `os.PathLike`, *optional*): Path to a directory in which a downloaded pretrained model configuration should be cached if the standard cache should not be used. force_download (`bool`, *optional*, defaults to `False`): Whether or not to force to (re-)download the configuration files and override the cached versions if they exist. resume_download (`bool`, *optional*, defaults to `False`): Whether or not to delete incompletely received file. Attempts to resume the download if such a file exists. proxies (`Dict[str, str]`, *optional*): A dictionary of proxy servers to use by protocol or endpoint, e.g., `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}.` The proxies are used on each request. use_auth_token (`str` or *bool*, *optional*): The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated when running `transformers-cli login` (stored in `~/.huggingface`). revision(`str`, *optional*, defaults to `"main"`): The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any identifier allowed by git. local_files_only (`bool`, *optional*, defaults to `False`): If `True`, will only try to load the tokenizer configuration from local files. Passing `use_auth_token=True` is required when you want to use a private model. Returns: `type`: The class, dynamically imported from the module. Examples: ```python # Download module *modeling.py* from huggingface.co and cache then extract the class *MyBertModel* from this # module. cls = get_class_from_dynamic_module("sgugger/my-bert-model", "modeling.py", "MyBertModel") ```z+Offline mode: forcing local_files_only=TrueTlocalN)r3rEZmirror/)r@rArCrBrFrDzCould not locate the z inside rz.py_)r loggerinfostrrrisdirr2r r7r8r EnvironmentErrorerrorr6rrrrshutilcopyrr!rr=)r>r?r:r@rArBrCrDrErFkwargsZmodule_file_or_url submoduleZresolved_module_fileZfull_submoduleZsubmodule_path module_nameZresolved_module_file_nameZmodule_name_partsZ final_modulerrrget_class_from_dynamic_moduleksHJ      rV)NFFNNNF)__doc__r.rr)rQrpathlibrtypingrrrZ file_utilsrrr r r utilsr get_logger__name__rKrrMPathLikerr6r=boolrVrrrrs*