docstr: Create an empty repo on the HuggingFace Hub and upload trained model artifacts to that repo.
  
  Args:
      repo_id (`str`):
          A namespace (user or an organization) and a repo name separated
          by a `/`.
      model_path (`str`):
          The path of the saved model. This is the top level directory where
          the models weights as well as other associated training artifacts
          are saved.
      repo_type (`str`, *optional*):
          Set to `"dataset"` or `"space"` if uploading to a dataset or
          space, `None` or `"model"` if uploading to a model. Default is
          `None`.
      private (`bool`, *optional*, defaults to `False`):
          Whether the model repo should be private.
      commit_message (`str`, *optional*):
          The summary / title / first line of the generated commit. Defaults to:
          `f"Upload {path_in_repo} with huggingface_hub"`
      commit_description (`str` *optional*):
          The description of the generated commit
docstr_tok: ["Create","an","empty","repo","on","the","HuggingFace","Hub","and","upload","trained","model","artifacts","to","that","repo",".","Args",":","repo_id","(","`","str","`",")",":","A","namespace","(","user","or","an","organization",")","and","a","repo","name","separated","by","a","`","\/","`",".","model_path","(","`","str","`",")",":","The","path","of","the","saved","model",".","This","is","the","top","level","directory","where","the","models","weights","as","well","as","other","associated","training","artifacts","are","saved",".","repo_type","(","`","str","`",",","*","optional","*",")",":","Set","to","`","``","dataset","''","`","or","`","``","space","''","`","if","uploading","to","a","dataset","or","space",",","`","None","`","or","`","``","model","''","`","if","uploading","to","a","model",".","Default","is","`","None","`",".","private","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","the","model","repo","should","be","private",".","commit_message","(","`","str","`",",","*","optional","*",")",":","The","summary","\/","title","\/","first","line","of","the","generated","commit",".","Defaults","to",":","`","f","''","Upload","{","path_in_repo","}","with","huggingface_hub","''","`","commit_description","(","`","str","`","*","optional","*",")",":","The","description","of","the","generated","commit"]
code: def upload(
      self,
      repo_id: str,
      model_path: str,
      repo_type: str | None = None,
      private: bool | None = False,
      commit_message: str | None = None,
      commit_description: str | None = None,
      **kwargs,
  ) -> bool:
      """Create an empty repo on the HuggingFace Hub and upload trained model artifacts to that repo.
  
      Args:
          repo_id (`str`):
              A namespace (user or an organization) and a repo name separated
              by a `/`.
          model_path (`str`):
              The path of the saved model. This is the top level directory where
              the models weights as well as other associated training artifacts
              are saved.
          repo_type (`str`, *optional*):
              Set to `"dataset"` or `"space"` if uploading to a dataset or
              space, `None` or `"model"` if uploading to a model. Default is
              `None`.
          private (`bool`, *optional*, defaults to `False`):
              Whether the model repo should be private.
          commit_message (`str`, *optional*):
              The summary / title / first line of the generated commit. Defaults to:
              `f"Upload {path_in_repo} with huggingface_hub"`
          commit_description (`str` *optional*):
              The description of the generated commit
      """
      # Validate upload parameters are in the right format
      HuggingFaceHub._validate_upload_parameters(
          repo_id,
          model_path,
          repo_type,
          private,
          commit_message,
          commit_description,
      )
  
      # Create empty model repo using repo_id, but it is okay if it already exists.
      self.api.create_repo(
          repo_id=repo_id,
          private=private,
          repo_type=repo_type,
          exist_ok=True,
      )
  
      # Upload all artifacts in model weights folder
      upload_path = self.api.upload_folder(
          folder_path=os.path.join(
              model_path, "model", "model_weights"
          ),
          repo_id=repo_id,
          repo_type=repo_type,
          commit_message=commit_message,
          commit_description=commit_description,
      )
  
      if upload_path:
          logger.info(
              f"Model uploaded to `{upload_path}` with repository name `{repo_id}`"
          )
          return True
  
      return False
  
imports: from __future__ import annotations
  import logging
  import os
  from abc import ABC, abstractmethod
  from huggingface_hub import HfApi, login
label_desc: Use image node_id 4 for calling the HuggingFaceHub obj's underlying member method code with example usage: obj.upload(repo_id, model_path, repo_type, private, commit_message, commit_description) and returns: False, True