docstr: Register model artifacts with this function. These artifacts (files) will be included inside .nemo file
  when model.save_to("mymodel.nemo") is called.
  
  How it works:
  
  1. It always returns existing absolute path which can be used during Model constructor call
      EXCEPTION: src is None or "" in which case nothing will be done and src will be returned
  2. It will add (config_path, model_utils.ArtifactItem()) pair to self.artifacts
  
      .. code-block::
  
        If "src" is local existing path:
            then it will be returned in absolute path form
        elif "src" starts with "nemo_file:unique_artifact_name":
            .nemo will be untarred to a temporary folder location and an actual existing path will be returned
        else:
            an error will be raised.
  
  WARNING: use .register_artifact calls in your models' constructors.
  The returned path is not guaranteed to exist after you have exited your model's constructor.
  
  Args:
      model: ModelPT object to register artifact for.
      config_path (str): Artifact key. Usually corresponds to the model config.
      src (str): Path to artifact.
      verify_src_exists (bool): If set to False, then the artifact is optional and register_artifact will return
          None even if src is not found. Defaults to True.
  
  Returns:
      str: If src is not None or empty it always returns absolute path which is guaranteed to exists during model
          instance life
code: def register_artifact(
      self,
      model,
      config_path: str,
      src: str,
      verify_src_exists: bool = True,
  ):
      """
      Register model artifacts with this function. These artifacts (files) will be included inside .nemo file
      when model.save_to("mymodel.nemo") is called.
  
      How it works:
  
      1. It always returns existing absolute path which can be used during Model constructor call
          EXCEPTION: src is None or "" in which case nothing will be done and src will be returned
      2. It will add (config_path, model_utils.ArtifactItem()) pair to self.artifacts
  
          .. code-block::
  
            If "src" is local existing path:
                then it will be returned in absolute path form
            elif "src" starts with "nemo_file:unique_artifact_name":
                .nemo will be untarred to a temporary folder location and an actual existing path will be returned
            else:
                an error will be raised.
  
      WARNING: use .register_artifact calls in your models' constructors.
      The returned path is not guaranteed to exist after you have exited your model's constructor.
  
      Args:
          model: ModelPT object to register artifact for.
          config_path (str): Artifact key. Usually corresponds to the model config.
          src (str): Path to artifact.
          verify_src_exists (bool): If set to False, then the artifact is optional and register_artifact will return
              None even if src is not found. Defaults to True.
  
      Returns:
          str: If src is not None or empty it always returns absolute path which is guaranteed to exists during model
              instance life
      """
      app_state = AppState()
  
      artifact_item = model_utils.ArtifactItem()
  
      # This is for backward compatibility, if the src objects exists simply inside of the tarfile
      # without its key having been overriden, this pathway will be used.
      src_obj_name = os.path.basename(src)
      if app_state.nemo_file_folder is not None:
          src_obj_path = os.path.abspath(
              os.path.join(app_state.nemo_file_folder, src_obj_name)
          )
      else:
          src_obj_path = src_obj_name
  
      # src is a local existing path - register artifact and return exact same path for usage by the model
      if os.path.exists(os.path.abspath(src)):
          return_path = os.path.abspath(src)
          artifact_item.path_type = (
              model_utils.ArtifactPathType.LOCAL_PATH
          )
  
      # this is the case when artifact must be retried from the nemo file
      # we are assuming that the location of the right nemo file is available from _MODEL_RESTORE_PATH
      elif src.startswith("nemo:"):
          return_path = os.path.abspath(
              os.path.join(app_state.nemo_file_folder, src[5:])
          )
          artifact_item.path_type = (
              model_utils.ArtifactPathType.TAR_PATH
          )
  
      # backward compatibility implementation
      elif os.path.exists(src_obj_path):
          return_path = src_obj_path
          artifact_item.path_type = (
              model_utils.ArtifactPathType.TAR_PATH
          )
      else:
          if verify_src_exists:
              raise FileNotFoundError(
                  f"src path does not exist or it is not a path in nemo file. src value I got was: {src}. Absolute: {os.path.abspath(src)}"
              )
          else:
              # artifact is optional and we simply return None
              logging.warning(
                  f"src path does not exist or it is not a path in nemo file. src value I got was: {src}. Absolute: {os.path.abspath(src)}"
              )
              return None
  
      assert os.path.exists(return_path)
  
      artifact_item.path = os.path.abspath(src)
      model.artifacts[config_path] = artifact_item
      # we were called by ModelPT
      if hasattr(model, "cfg"):
          with open_dict(model._cfg):
              OmegaConf.update(model.cfg, config_path, return_path)
      return return_path
  
imports: from __future__ import annotations
  import os
  import shutil
  import tarfile
  import tempfile
  import uuid
  from typing import Optional, Set, Union
  import torch
  from omegaconf import DictConfig, OmegaConf
  from omegaconf.omegaconf import open_dict
  from pytorch_lightning.trainer.trainer import Trainer
  from nemo.core import classes
  from nemo.utils import logging, model_utils
  from nemo.utils.app_state import AppState
  from nemo.utils.get_rank import is_global_rank_zero
  from nemo.utils.model_utils import inject_model_parallel_rank
label_desc: Use image node_id 8 for calling the SaveRestoreConnector obj's underlying member method code with example usage: obj.register_artifact(model, config_path, src, verify_src_exists) and returns: return_path, None