class_docstr: A mixin for saving and loading models to the
  `Huggingface Model Hub <https://huggingface.co/docs/hub/index>`_.
  
  .. code-block:: python
  
     from torch_geometric.datasets import Planetoid
     from torch_geometric.nn import Node2Vec
     from torch_geometric.nn.model_hub import PyGModelHubMixin
  
     # Define your class with the mixin:
     class N2V(Node2Vec, PyGModelHubMixin):
         def __init__(self,model_name, dataset_name, model_kwargs):
             Node2Vec.__init__(self,**model_kwargs)
             PyGModelHubMixin.__init__(self, model_name,
                 dataset_name, model_kwargs)
  
     # Instantiate your model:
     n2v = N2V(model_name='node2vec',
         dataset_name='Cora', model_kwargs=dict(
         edge_index=data.edge_index, embedding_dim=128,
         walk_length=20, context_size=10, walks_per_node=10,
         num_negative_samples=1, p=1, q=1, sparse=True))
  
     # Train the model:
     ...
  
     # Push to the HuggingFace hub:
     repo_id = ...  # your repo id
     n2v.save_pretrained(
         local_file_path,
         push_to_hub=True,
         repo_id=repo_id,
      )
  
     # Load the model for inference:
     # The required arguments are the repo id/local folder, and any model
     # initialisation arguments that are not native python types (e.g
     # Node2Vec requires the edge_index argument which is not stored in the
     # model hub).
     model = N2V.from_pretrained(
         repo_id,
         model_name='node2vec',
         dataset_name='Cora',
         edge_index=data.edge_index,
     )
  
  Args:
      model_name (str): Name of the model.
      dataset_name (str): Name of the dataset the model was trained against.
      model_kwargs (Dict[str, Any]): The arguments to initialise the model.
class_docstr_tok: ["A","mixin","for","saving","and","loading","models","to","the","`","Huggingface","Model","Hub","<","https",":","\/\/huggingface.co\/docs\/hub\/index",">","`","_",".","..","code-block",":",":","python","from","torch_geometric.datasets","import","Planetoid","from","torch_geometric.nn","import","Node2Vec","from","torch_geometric.nn.model_hub","import","PyGModelHubMixin","#","Define","your","class","with","the","mixin",":","class","N2V","(","Node2Vec",",","PyGModelHubMixin",")",":","def","__init__","(","self",",","model_name",",","dataset_name",",","model_kwargs",")",":","Node2Vec.__init__","(","self",",","*","*","model_kwargs",")","PyGModelHubMixin.__init__","(","self",",","model_name",",","dataset_name",",","model_kwargs",")","#","Instantiate","your","model",":","n2v","=","N2V","(","model_name='node2vec","'",",","dataset_name='Cora","'",",","model_kwargs=dict","(","edge_index=data.edge_index",",","embedding_dim=128",",","walk_length=20",",","context_size=10",",","walks_per_node=10",",","num_negative_samples=1",",","p=1",",","q=1",",","sparse=True",")",")","#","Train","the","model",":","...","#","Push","to","the","HuggingFace","hub",":","repo_id","=","...","#","your","repo","id","n2v.save_pretrained","(","local_file_path",",","push_to_hub=True",",","repo_id=repo_id",",",")","#","Load","the","model","for","inference",":","#","The","required","arguments","are","the","repo","id\/local","folder",",","and","any","model","#","initialisation","arguments","that","are","not","native","python","types","(","e.g","#","Node2Vec","requires","the","edge_index","argument","which","is","not","stored","in","the","#","model","hub",")",".","model","=","N2V.from_pretrained","(","repo_id",",","model_name='node2vec","'",",","dataset_name='Cora","'",",","edge_index=data.edge_index",",",")","Args",":","model_name","(","str",")",":","Name","of","the","model",".","dataset_name","(","str",")",":","Name","of","the","dataset","the","model","was","trained","against",".","model_kwargs","(","Dict","[","str",",","Any","]",")",":","The","arguments","to","initialise","the","model","."]
docstr: Downloads and instantiates a model from the HuggingFace hub.
  
  Args:
      pretrained_model_name_or_path (str): Can be either:
  
          - The :obj:`model_id` of a pretrained model hosted inside the
            HuggingFace hub.
  
          - You can add a :obj:`revision` by appending :obj:`@` at the
            end of :obj:`model_id` to load a specific model version.
  
          - A path to a directory containing the saved model weights.
  
          - :obj:`None` if you are both providing the configuration
            :obj:`config` and state dictionary :obj:`state_dict`.
  
      force_download (bool, optional): Whether to force the
          (re-)download of the model weights and configuration files,
          overriding the cached versions if they exist.
          (default: :obj:`False`)
      resume_download (bool, optional): Whether to delete incompletely
          received files. Will attempt to resume the download if such a
          file exists. (default: :obj:`False`)
      proxies (Dict[str, str], optional): A dictionary of proxy servers
          to use by protocol or endpoint, *e.g.*,
          :obj:`{'http': 'foo.bar:3128', 'http://host': 'foo.bar:4012'}`.
          The proxies are used on each request. (default: :obj:`None`)
      token (str or bool, optional): The token to use as HTTP bearer
          authorization for remote files. If set to :obj:`True`, will use
          the token generated when running :obj:`transformers-cli login`
          (stored in :obj:`~/.huggingface`). It is **required** if you
          want to use a private model. (default: :obj:`None`)
      cache_dir (str, optional): The path to a directory in which a
          downloaded model configuration should be cached if the
          standard cache should not be used. (default: :obj:`None`)
      local_files_only (bool, optional): Whether to only look at local
          files, *i.e.* do not try to download the model.
          (default: :obj:`False`)
      **model_kwargs: Additional keyword arguments passed to the
          model during initialization.
docstr_tok: ["Downloads","and","instantiates","a","model","from","the","HuggingFace","hub",".","Args",":","pretrained_model_name_or_path","(","str",")",":","Can","be","either",":","-","The",":","obj",":","`","model_id","`","of","a","pretrained","model","hosted","inside","the","HuggingFace","hub",".","-","You","can","add","a",":","obj",":","`","revision","`","by","appending",":","obj",":","`","@","`","at","the","end","of",":","obj",":","`","model_id","`","to","load","a","specific","model","version",".","-","A","path","to","a","directory","containing","the","saved","model","weights",".","-",":","obj",":","`","None","`","if","you","are","both","providing","the","configuration",":","obj",":","`","config","`","and","state","dictionary",":","obj",":","`","state_dict","`",".","force_download","(","bool",",","optional",")",":","Whether","to","force","the","(","re-",")","download","of","the","model","weights","and","configuration","files",",","overriding","the","cached","versions","if","they","exist",".","(","default",":",":","obj",":","`","False","`",")","resume_download","(","bool",",","optional",")",":","Whether","to","delete","incompletely","received","files",".","Will","attempt","to","resume","the","download","if","such","a","file","exists",".","(","default",":",":","obj",":","`","False","`",")","proxies","(","Dict","[","str",",","str","]",",","optional",")",":","A","dictionary","of","proxy","servers","to","use","by","protocol","or","endpoint",",","*","e.g",".","*",",",":","obj",":","`","{","'http","'",":","'foo.bar:3128","'",",","'http",":","\/\/host","'",":","'foo.bar:4012","'","}","`",".","The","proxies","are","used","on","each","request",".","(","default",":",":","obj",":","`","None","`",")","token","(","str","or","bool",",","optional",")",":","The","token","to","use","as","HTTP","bearer","authorization","for","remote","files",".","If","set","to",":","obj",":","`","True","`",",","will","use","the","token","generated","when","running",":","obj",":","`","transformers-cli","login","`","(","stored","in",":","obj",":","`","~\/.huggingface","`",")",".","It","is","*","*","required","*","*","if","you","want","to","use","a","private","model",".","(","default",":",":","obj",":","`","None","`",")","cache_dir","(","str",",","optional",")",":","The","path","to","a","directory","in","which","a","downloaded","model","configuration","should","be","cached","if","the","standard","cache","should","not","be","used",".","(","default",":",":","obj",":","`","None","`",")","local_files_only","(","bool",",","optional",")",":","Whether","to","only","look","at","local","files",",","*","i.e",".","*","do","not","try","to","download","the","model",".","(","default",":",":","obj",":","`","False","`",")","*","*","model_kwargs",":","Additional","keyword","arguments","passed","to","the","model","during","initialization","."]
code: def from_pretrained(
      cls,
      pretrained_model_name_or_path: str,
      force_download: bool = False,
      resume_download: bool = False,
      proxies: Optional[Dict] = None,
      token: Optional[Union[str, bool]] = None,
      cache_dir: Optional[str] = None,
      local_files_only: bool = False,
      **model_kwargs,
  ) -> Any:
      r"""Downloads and instantiates a model from the HuggingFace hub.
  
      Args:
          pretrained_model_name_or_path (str): Can be either:
  
              - The :obj:`model_id` of a pretrained model hosted inside the
                HuggingFace hub.
  
              - You can add a :obj:`revision` by appending :obj:`@` at the
                end of :obj:`model_id` to load a specific model version.
  
              - A path to a directory containing the saved model weights.
  
              - :obj:`None` if you are both providing the configuration
                :obj:`config` and state dictionary :obj:`state_dict`.
  
          force_download (bool, optional): Whether to force the
              (re-)download of the model weights and configuration files,
              overriding the cached versions if they exist.
              (default: :obj:`False`)
          resume_download (bool, optional): Whether to delete incompletely
              received files. Will attempt to resume the download if such a
              file exists. (default: :obj:`False`)
          proxies (Dict[str, str], optional): A dictionary of proxy servers
              to use by protocol or endpoint, *e.g.*,
              :obj:`{'http': 'foo.bar:3128', 'http://host': 'foo.bar:4012'}`.
              The proxies are used on each request. (default: :obj:`None`)
          token (str or bool, optional): The token to use as HTTP bearer
              authorization for remote files. If set to :obj:`True`, will use
              the token generated when running :obj:`transformers-cli login`
              (stored in :obj:`~/.huggingface`). It is **required** if you
              want to use a private model. (default: :obj:`None`)
          cache_dir (str, optional): The path to a directory in which a
              downloaded model configuration should be cached if the
              standard cache should not be used. (default: :obj:`None`)
          local_files_only (bool, optional): Whether to only look at local
              files, *i.e.* do not try to download the model.
              (default: :obj:`False`)
          **model_kwargs: Additional keyword arguments passed to the
              model during initialization.
      """
      return super().from_pretrained(
          pretrained_model_name_or_path,
          force_download=force_download,
          resume_download=resume_download,
          proxies=proxies,
          use_auth_token=token,
          cache_dir=cache_dir,
          local_files_only=local_files_only,
          **model_kwargs,
      )
  
file_path: pytorch_geometric/torch_geometric/nn/model_hub.py
imports: import os.path
  from pathlib import Path
  from typing import Any, Dict, Optional, Union
  import torch
label_desc: Use image node_id 6 for calling the PyGModelHubMixin obj's underlying member method code with example usage: obj.from_pretrained(cls, pretrained_model_name_or_path, force_download, resume_download, proxies, token, cache_dir, local_files_only) and returns: super