class_docstr: A Mixin containing the functionality to push a model or tokenizer to the hub.
class_docstr_tok: ["A","Mixin","containing","the","functionality","to","push","a","model","or","tokenizer","to","the","hub","."]
docstr: Upload the {object_files} to the 🤗 Model Hub while synchronizing a local clone of the repo in
  `repo_path_or_name`.
  
  Parameters:
      repo_id (`str`):
          The name of the repository you want to push your {object} to. It should contain your organization name
          when pushing to a given organization.
      use_temp_dir (`bool`, *optional*):
          Whether or not to use a temporary directory to store the files saved before they are pushed to the Hub.
          Will default to `True` if there is no directory named like `repo_id`, `False` otherwise.
      commit_message (`str`, *optional*):
          Message to commit while pushing. Will default to `"Upload {object}"`.
      private (`bool`, *optional*):
          Whether or not the repository created should be private (requires a paying subscription).
      use_auth_token (`bool` or `str`, *optional*):
          The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
          when running `huggingface-cli login` (stored in `~/.huggingface`). Will default to `True` if `repo_url`
          is not specified.
      max_shard_size (`int` or `str`, *optional*, defaults to `"10GB"`):
          Only applicable for models. The maximum size for a checkpoint before being sharded. Checkpoints shard
          will then be each of size lower than this size. If expressed as a string, needs to be digits followed
          by a unit (like `"5MB"`).
      create_pr (`bool`, *optional*, defaults to `False`):
          Whether or not to create a PR with the uploaded files or directly commit.
  
  Examples:
  
  ```python
  from transformers import {object_class}
  
  {object} = {object_class}.from_pretrained("bert-base-cased")
  
  # Push the {object} to your namespace with the name "my-finetuned-bert".
  {object}.push_to_hub("my-finetuned-bert")
  
  # Push the {object} to an organization with the name "my-finetuned-bert".
  {object}.push_to_hub("huggingface/my-finetuned-bert")
  ```
docstr_tok: ["Upload","the","{","object_files","}","to","the","\ud83e\udd17","Model","Hub","while","synchronizing","a","local","clone","of","the","repo","in","`","repo_path_or_name","`",".","Parameters",":","repo_id","(","`","str","`",")",":","The","name","of","the","repository","you","want","to","push","your","{","object","}","to",".","It","should","contain","your","organization","name","when","pushing","to","a","given","organization",".","use_temp_dir","(","`","bool","`",",","*","optional","*",")",":","Whether","or","not","to","use","a","temporary","directory","to","store","the","files","saved","before","they","are","pushed","to","the","Hub",".","Will","default","to","`","True","`","if","there","is","no","directory","named","like","`","repo_id","`",",","`","False","`","otherwise",".","commit_message","(","`","str","`",",","*","optional","*",")",":","Message","to","commit","while","pushing",".","Will","default","to","`","``","Upload","{","object","}","''","`",".","private","(","`","bool","`",",","*","optional","*",")",":","Whether","or","not","the","repository","created","should","be","private","(","requires","a","paying","subscription",")",".","use_auth_token","(","`","bool","`","or","`","str","`",",","*","optional","*",")",":","The","token","to","use","as","HTTP","bearer","authorization","for","remote","files",".","If","`","True","`",",","will","use","the","token","generated","when","running","`","huggingface-cli","login","`","(","stored","in","`","~\/.huggingface","`",")",".","Will","default","to","`","True","`","if","`","repo_url","`","is","not","specified",".","max_shard_size","(","`","int","`","or","`","str","`",",","*","optional","*",",","defaults","to","`","``","10GB","''","`",")",":","Only","applicable","for","models",".","The","maximum","size","for","a","checkpoint","before","being","sharded",".","Checkpoints","shard","will","then","be","each","of","size","lower","than","this","size",".","If","expressed","as","a","string",",","needs","to","be","digits","followed","by","a","unit","(","like","`","``","5MB","''","`",")",".","create_pr","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","or","not","to","create","a","PR","with","the","uploaded","files","or","directly","commit",".","Examples",":","``","`","python","from","transformers","import","{","object_class","}","{","object","}","=","{","object_class","}",".from_pretrained","(","``","bert-base-cased","''",")","#","Push","the","{","object","}","to","your","namespace","with","the","name","``","my-finetuned-bert","''",".","{","object","}",".push_to_hub","(","``","my-finetuned-bert","''",")","#","Push","the","{","object","}","to","an","organization","with","the","name","``","my-finetuned-bert","''",".","{","object","}",".push_to_hub","(","``","huggingface\/my-finetuned-bert","''",")","``","`"]
code: def push_to_hub(
      self,
      repo_id: str,
      use_temp_dir: Optional[bool] = None,
      commit_message: Optional[str] = None,
      private: Optional[bool] = None,
      use_auth_token: Optional[Union[bool, str]] = None,
      max_shard_size: Optional[Union[int, str]] = "10GB",
      create_pr: bool = False,
      **deprecated_kwargs,
  ) -> str:
      """
      Upload the {object_files} to the 🤗 Model Hub while synchronizing a local clone of the repo in
      `repo_path_or_name`.
  
      Parameters:
          repo_id (`str`):
              The name of the repository you want to push your {object} to. It should contain your organization name
              when pushing to a given organization.
          use_temp_dir (`bool`, *optional*):
              Whether or not to use a temporary directory to store the files saved before they are pushed to the Hub.
              Will default to `True` if there is no directory named like `repo_id`, `False` otherwise.
          commit_message (`str`, *optional*):
              Message to commit while pushing. Will default to `"Upload {object}"`.
          private (`bool`, *optional*):
              Whether or not the repository created should be private (requires a paying subscription).
          use_auth_token (`bool` or `str`, *optional*):
              The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated
              when running `huggingface-cli login` (stored in `~/.huggingface`). Will default to `True` if `repo_url`
              is not specified.
          max_shard_size (`int` or `str`, *optional*, defaults to `"10GB"`):
              Only applicable for models. The maximum size for a checkpoint before being sharded. Checkpoints shard
              will then be each of size lower than this size. If expressed as a string, needs to be digits followed
              by a unit (like `"5MB"`).
          create_pr (`bool`, *optional*, defaults to `False`):
              Whether or not to create a PR with the uploaded files or directly commit.
  
      Examples:
  
      ```python
      from transformers import {object_class}
  
      {object} = {object_class}.from_pretrained("bert-base-cased")
  
      # Push the {object} to your namespace with the name "my-finetuned-bert".
      {object}.push_to_hub("my-finetuned-bert")
  
      # Push the {object} to an organization with the name "my-finetuned-bert".
      {object}.push_to_hub("huggingface/my-finetuned-bert")
      ```
      """
      if "repo_path_or_name" in deprecated_kwargs:
          warnings.warn(
              "The `repo_path_or_name` argument is deprecated and will be removed in v5 of Transformers. Use "
              "`repo_id` instead."
          )
          repo_id = deprecated_kwargs.pop("repo_path_or_name")
      # Deprecation warning will be sent after for repo_url and organization
      repo_url = deprecated_kwargs.pop("repo_url", None)
      organization = deprecated_kwargs.pop("organization", None)
  
      if os.path.isdir(repo_id):
          working_dir = repo_id
          repo_id = repo_id.split(os.path.sep)[-1]
      else:
          working_dir = repo_id.split("/")[-1]
  
      repo_id, token = self._create_repo(
          repo_id,
          private=private,
          use_auth_token=use_auth_token,
          repo_url=repo_url,
          organization=organization,
      )
  
      if use_temp_dir is None:
          use_temp_dir = not os.path.isdir(working_dir)
  
      with working_or_temp_dir(
          working_dir=working_dir, use_temp_dir=use_temp_dir
      ) as work_dir:
          files_timestamps = self._get_files_timestamps(work_dir)
  
          # Save all files.
          self.save_pretrained(work_dir, max_shard_size=max_shard_size)
  
          return self._upload_modified_files(
              work_dir,
              repo_id,
              files_timestamps,
              commit_message=commit_message,
              token=token,
              create_pr=create_pr,
          )
  
imports: import json
  import os
  import re
  import shutil
  import sys
  import tempfile
  import traceback
  import warnings
  from pathlib import Path
  from typing import Dict, List, Optional, Tuple, Union
  from urllib.parse import urlparse
  from uuid import uuid4
  import huggingface_hub
  import requests
  from huggingface_hub import CommitOperationAdd, HfFolder, create_commit, create_repo, get_hf_file_metadata, hf_hub_download, hf_hub_url, whoami
  from huggingface_hub.file_download import REGEX_COMMIT_HASH, http_get
  from huggingface_hub.utils import EntryNotFoundError, LocalEntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError, hf_raise_for_status
  from requests.exceptions import HTTPError
  from transformers.utils.logging import tqdm
  from .None import __version__, logging
  from .generic import working_or_temp_dir
  from .import_utils import ENV_VARS_TRUE_VALUES, _tf_version, _torch_version, is_tf_available, is_torch_available, is_training_run_on_sagemaker
label_desc: Use image node_id 4 for calling the PushToHubMixin obj's underlying member method code with example usage: obj.push_to_hub(repo_id, use_temp_dir, commit_message, private, use_auth_token, max_shard_size, create_pr) and returns: self