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: Save a trained model to a local directory or to the HuggingFace
  model hub.
  
  Args:
      save_directory (str): The directory where weights are saved.
      push_to_hub (bool, optional): If :obj:`True`, push the model to the
          HuggingFace model hub. (default: :obj:`False`)
      repo_id (str, optional): The repository name in the hub.
          If not provided will default to the name of
          :obj:`save_directory` in your namespace. (default: :obj:`None`)
      **kwargs: Additional keyword arguments passed to
          :meth:`huggingface_hub.ModelHubMixin.save_pretrained`.
docstr_tok: ["Save","a","trained","model","to","a","local","directory","or","to","the","HuggingFace","model","hub",".","Args",":","save_directory","(","str",")",":","The","directory","where","weights","are","saved",".","push_to_hub","(","bool",",","optional",")",":","If",":","obj",":","`","True","`",",","push","the","model","to","the","HuggingFace","model","hub",".","(","default",":",":","obj",":","`","False","`",")","repo_id","(","str",",","optional",")",":","The","repository","name","in","the","hub",".","If","not","provided","will","default","to","the","name","of",":","obj",":","`","save_directory","`","in","your","namespace",".","(","default",":",":","obj",":","`","None","`",")","*","*","kwargs",":","Additional","keyword","arguments","passed","to",":","meth",":","`","huggingface_hub.ModelHubMixin.save_pretrained","`","."]
code: def save_pretrained(
      self,
      save_directory: Union[str, Path],
      push_to_hub: bool = False,
      repo_id: Optional[str] = None,
      **kwargs,
  ):
      r"""Save a trained model to a local directory or to the HuggingFace
      model hub.
  
      Args:
          save_directory (str): The directory where weights are saved.
          push_to_hub (bool, optional): If :obj:`True`, push the model to the
              HuggingFace model hub. (default: :obj:`False`)
          repo_id (str, optional): The repository name in the hub.
              If not provided will default to the name of
              :obj:`save_directory` in your namespace. (default: :obj:`None`)
          **kwargs: Additional keyword arguments passed to
              :meth:`huggingface_hub.ModelHubMixin.save_pretrained`.
      """
      config = self.model_config
      # due to way huggingface hub handles the loading/saving of models,
      # the model config can end up in one of the items in the kwargs
      # this has to be removed to prevent a duplication of arguments to
      # ModelHubMixin.save_pretrained
      kwargs.pop("config", None)
  
      super().save_pretrained(
          save_directory=save_directory,
          config=config,
          push_to_hub=push_to_hub,
          repo_id=repo_id,
          **kwargs,
      )
      model_card = self.construct_model_card(
          self.model_name, self.dataset_name
      )
      if push_to_hub:
          model_card.push_to_hub(repo_id)
  
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 4 for calling the PyGModelHubMixin obj's underlying member method code with example usage: obj.save_pretrained(save_directory, push_to_hub, repo_id) without return types