class_docstr: A generic mixin to integrate ANY machine learning framework with the Hub.
  
  To integrate your framework, your model class must inherit from this class. Custom logic for saving/loading models
  have to be overwritten in  [`_from_pretrained`] and [`_save_pretrained`]. [`PyTorchModelHubMixin`] is a good example
  of mixin integration with the Hub. Check out our [integration guide](../guides/integrations) for more instructions.
class_docstr_tok: ["A","generic","mixin","to","integrate","ANY","machine","learning","framework","with","the","Hub",".","To","integrate","your","framework",",","your","model","class","must","inherit","from","this","class",".","Custom","logic","for","saving\/loading","models","have","to","be","overwritten","in","[","`","_from_pretrained","`","]","and","[","`","_save_pretrained","`","]",".","[","`","PyTorchModelHubMixin","`","]","is","a","good","example","of","mixin","integration","with","the","Hub",".","Check","out","our","[","integration","guide","]","(","..","\/guides\/integrations",")","for","more","instructions","."]
docstr: Overwrite this method in subclass to define how to load your model from pretrained.
  
  Use [`hf_hub_download`] or [`snapshot_download`] to download files from the Hub before loading them. Most
  args taken as input can be directly passed to those 2 methods. If needed, you can add more arguments to this
  method using "model_kwargs". For example [`PyTorchModelHubMixin._from_pretrained`] takes as input a `map_location`
  parameter to set on which device the model should be loaded.
  
  Check out our [integration guide](../guides/integrations) for more instructions.
  
  Args:
      model_id (`str`):
          ID of the model to load from the Huggingface Hub (e.g. `bigscience/bloom`).
      revision (`str`, *optional*):
          Revision of the model on the Hub. Can be a branch name, a git tag or any commit id. Defaults to the
          latest commit on `main` branch.
      force_download (`bool`, *optional*, defaults to `False`):
          Whether to force (re-)downloading the model weights and configuration files from the Hub, overriding
          the existing cache.
      resume_download (`bool`, *optional*, defaults to `False`):
          Whether to delete incompletely received files. Will attempt 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'}`).
      token (`str` or `bool`, *optional*):
          The token to use as HTTP bearer authorization for remote files. By default, it will use the token
          cached when running `huggingface-cli login`.
      cache_dir (`str`, `Path`, *optional*):
          Path to the folder where cached files are stored.
      local_files_only (`bool`, *optional*, defaults to `False`):
          If `True`, avoid downloading the file and return the path to the local cached file if it exists.
      model_kwargs:
          Additional keyword arguments passed along to the [`~ModelHubMixin._from_pretrained`] method.
docstr_tok: ["Overwrite","this","method","in","subclass","to","define","how","to","load","your","model","from","pretrained",".","Use","[","`","hf_hub_download","`","]","or","[","`","snapshot_download","`","]","to","download","files","from","the","Hub","before","loading","them",".","Most","args","taken","as","input","can","be","directly","passed","to","those","2","methods",".","If","needed",",","you","can","add","more","arguments","to","this","method","using","``","model_kwargs","''",".","For","example","[","`","PyTorchModelHubMixin._from_pretrained","`","]","takes","as","input","a","`","map_location","`","parameter","to","set","on","which","device","the","model","should","be","loaded",".","Check","out","our","[","integration","guide","]","(","..","\/guides\/integrations",")","for","more","instructions",".","Args",":","model_id","(","`","str","`",")",":","ID","of","the","model","to","load","from","the","Huggingface","Hub","(","e.g",".","`","bigscience\/bloom","`",")",".","revision","(","`","str","`",",","*","optional","*",")",":","Revision","of","the","model","on","the","Hub",".","Can","be","a","branch","name",",","a","git","tag","or","any","commit","id",".","Defaults","to","the","latest","commit","on","`","main","`","branch",".","force_download","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","to","force","(","re-",")","downloading","the","model","weights","and","configuration","files","from","the","Hub",",","overriding","the","existing","cache",".","resume_download","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","to","delete","incompletely","received","files",".","Will","attempt","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","'","}","`",")",".","token","(","`","str","`","or","`","bool","`",",","*","optional","*",")",":","The","token","to","use","as","HTTP","bearer","authorization","for","remote","files",".","By","default",",","it","will","use","the","token","cached","when","running","`","huggingface-cli","login","`",".","cache_dir","(","`","str","`",",","`","Path","`",",","*","optional","*",")",":","Path","to","the","folder","where","cached","files","are","stored",".","local_files_only","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","If","`","True","`",",","avoid","downloading","the","file","and","return","the","path","to","the","local","cached","file","if","it","exists",".","model_kwargs",":","Additional","keyword","arguments","passed","along","to","the","[","`","~ModelHubMixin._from_pretrained","`","]","method","."]
code: def _from_pretrained(
      cls: Type[T],
      *,
      model_id: str,
      revision: Optional[str],
      cache_dir: Optional[Union[str, Path]],
      force_download: bool,
      proxies: Optional[Dict],
      resume_download: bool,
      local_files_only: bool,
      token: Optional[Union[str, bool]],
      **model_kwargs,
  ) -> T:
      """Overwrite this method in subclass to define how to load your model from pretrained.
  
      Use [`hf_hub_download`] or [`snapshot_download`] to download files from the Hub before loading them. Most
      args taken as input can be directly passed to those 2 methods. If needed, you can add more arguments to this
      method using "model_kwargs". For example [`PyTorchModelHubMixin._from_pretrained`] takes as input a `map_location`
      parameter to set on which device the model should be loaded.
  
      Check out our [integration guide](../guides/integrations) for more instructions.
  
      Args:
          model_id (`str`):
              ID of the model to load from the Huggingface Hub (e.g. `bigscience/bloom`).
          revision (`str`, *optional*):
              Revision of the model on the Hub. Can be a branch name, a git tag or any commit id. Defaults to the
              latest commit on `main` branch.
          force_download (`bool`, *optional*, defaults to `False`):
              Whether to force (re-)downloading the model weights and configuration files from the Hub, overriding
              the existing cache.
          resume_download (`bool`, *optional*, defaults to `False`):
              Whether to delete incompletely received files. Will attempt 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'}`).
          token (`str` or `bool`, *optional*):
              The token to use as HTTP bearer authorization for remote files. By default, it will use the token
              cached when running `huggingface-cli login`.
          cache_dir (`str`, `Path`, *optional*):
              Path to the folder where cached files are stored.
          local_files_only (`bool`, *optional*, defaults to `False`):
              If `True`, avoid downloading the file and return the path to the local cached file if it exists.
          model_kwargs:
              Additional keyword arguments passed along to the [`~ModelHubMixin._from_pretrained`] method.
      """
      raise NotImplementedError
  
file_path: hub-client/src/huggingface_hub/hub_mixin.py
imports: import json
  import os
  from pathlib import Path
  from typing import Dict, List, Optional, Type, TypeVar, Union
  from .constants import CONFIG_NAME, PYTORCH_WEIGHTS_NAME
  from .file_download import hf_hub_download, is_torch_available
  from .hf_api import HfApi
  from .utils import HfHubHTTPError, SoftTemporaryDirectory, logging, validate_hf_hub_args
label_desc: Use image node_id 4 for calling the ModelHubMixin obj's underlying member method code with example usage: obj._from_pretrained(cls) without return types