code: def push_to_hf_hub(
      model: torch.nn.Module,
      repo_id: str,
      commit_message: str = "Add model",
      token: Optional[str] = None,
      revision: Optional[str] = None,
      private: bool = False,
      create_pr: bool = False,
      model_config: Optional[dict] = None,
      model_card: Optional[dict] = None,
      model_args: Optional[dict] = None,
      safe_serialization: Union[bool, Literal["both"]] = False,
  ):
      """
      Arguments:
          (...)
          safe_serialization (`bool` or `"both"`, *optional*, defaults to `False`):
              Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
              Can be set to `"both"` in order to push both safe and unsafe weights.
      """
      # Create repo if it doesn't exist yet
      repo_url = create_repo(
          repo_id, token=token, private=private, exist_ok=True
      )
  
      # Infer complete repo_id from repo_url
      # Can be different from the input `repo_id` if repo_owner was implicit
      _, repo_owner, repo_name = repo_type_and_id_from_hf_id(repo_url)
      repo_id = f"{repo_owner}/{repo_name}"
  
      # Check if README file already exist in repo
      try:
          get_hf_file_metadata(
              hf_hub_url(
                  repo_id=repo_id,
                  filename="README.md",
                  revision=revision,
              )
          )
          has_readme = True
      except EntryNotFoundError:
          has_readme = False
  
      # Dump model and push to Hub
      with TemporaryDirectory() as tmpdir:
          # Save model weights and config.
          save_for_hf(
              model,
              tmpdir,
              model_config=model_config,
              model_args=model_args,
              safe_serialization=safe_serialization,
          )
  
          # Add readme if it does not exist
          if not has_readme:
              model_card = model_card or {}
              model_name = repo_id.split("/")[-1]
              readme_path = Path(tmpdir) / "README.md"
              readme_text = generate_readme(model_card, model_name)
              readme_path.write_text(readme_text)
  
          # Upload model and return
          return upload_folder(
              repo_id=repo_id,
              folder_path=tmpdir,
              revision=revision,
              create_pr=create_pr,
              commit_message=commit_message,
          )
  
imports: import hashlib
  import json
  import logging
  import os
  from functools import partial
  from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import Iterable, Optional, Union
  import torch
  from torch.hub import HASH_REGEX, download_url_to_file, urlparse
  from timm import __version__
  from timm.models._pretrained import filter_pretrained_cfg
label_desc: Use image node_id 12 for calling a global function with example usage: push_to_hf_hub(model, repo_id, commit_message, token, revision, private, create_pr, model_config, model_card, model_args, safe_serialization) and returns: upload_folder