code: def _add_variant(
      weights_name: str, variant: Optional[str] = None
  ) -> str:
      if variant is not None:
          splits = weights_name.split(".")
          splits = splits[:-1] + [variant] + splits[-1:]
          weights_name = ".".join(splits)
  
      return weights_name
  
imports: import os
  import re
  import sys
  import tempfile
  import traceback
  import warnings
  from pathlib import Path
  from typing import Dict, Optional, Union
  from uuid import uuid4
  from huggingface_hub import ModelCard, ModelCardData, create_repo, get_full_repo_name, hf_hub_download, upload_folder
  from huggingface_hub.constants import HF_HUB_CACHE, HF_HUB_DISABLE_TELEMETRY, HF_HUB_OFFLINE
  from huggingface_hub.file_download import REGEX_COMMIT_HASH
  from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError, is_jinja_available, validate_hf_hub_args
  from packaging import version
  from requests import HTTPError
  from ..None import __version__
  from .constants import DEPRECATED_REVISION_ARGS, HUGGINGFACE_CO_RESOLVE_ENDPOINT, SAFETENSORS_WEIGHTS_NAME, WEIGHTS_NAME
  from .import_utils import ENV_VARS_TRUE_VALUES, _flax_version, _jax_version, _onnxruntime_version, _torch_version, is_flax_available, is_onnx_available, is_torch_available
  from .logging import get_logger
label_desc: Use image node_id 5 for calling a global function with example usage: _add_variant(weights_name, variant) and returns: weights_name