code: def _add_hyperparam_experiments(
      exec_filename,
      other_args,
      runner_args,
      artifacts,
      resources_needed,
      logger,
      optimizer=None,
      hyperparam_tuples=None,
  ):
      experiment_name_base = (
          runner_args.experiment
          if runner_args.experiment
          else str(uuid.uuid4())
      )
  
      project = (
          runner_args.project
          if runner_args.project
          else ("hyperparam_" + experiment_name_base)
      )
  
      workspace_orig = (
          artifacts["workspace"]["local"]
          if "workspace" in artifacts.keys()
          else "."
      )
  
      ignore_arg = ""
      ignore_filepath = os.path.join(workspace_orig, ".studioml_ignore")
      if os.path.exists(ignore_filepath) and not os.path.isdir(
          ignore_filepath
      ):
          ignore_arg = "--exclude-from=%s" % ignore_filepath
  
      def create_experiments(hyperparam_tuples):
          experiments = []
          # experiment_names = {}
          for hyperparam_tuple in hyperparam_tuples:
              experiment_name = experiment_name_base
              experiment_name += "__opt__%s__%s" % (
                  util.rand_string(32),
                  int(time.time()),
              )
              experiment_name = experiment_name.replace(".", "_")
  
              workspace_new = fs_tracker.get_artifact_cache(
                  "workspace", experiment_name
              )
  
              current_artifacts = artifacts.copy()
              current_artifacts.update(
                  {
                      "workspace": {
                          "local": workspace_new,
                          "mutable": True,
                      }
                  }
              )
  
              rsync_cp(
                  workspace_orig, workspace_new, ignore_arg, logger
              )
              # shutil.copytree(workspace_orig, workspace_new)
  
              for param_name, param_value in six.iteritems(
                  hyperparam_tuple
              ):
                  if isinstance(param_value, np.ndarray):
                      array_filepath = "/tmp/%s.npy" % util.rand_string(
                          32
                      )
                      np.save(array_filepath, param_value)
                      assert param_name not in current_artifacts
                      current_artifacts[param_name] = {
                          "local": array_filepath,
                          "mutable": False,
                      }
                  else:
                      with open(
                          os.path.join(workspace_new, exec_filename),
                          "r",
                      ) as f:
                          script_text = f.read()
  
                      script_text = re.sub(
                          "\\b" + param_name + "\\b(?=[^=]*\\n)",
                          str(param_value),
                          script_text,
                      )
  
                      with open(
                          os.path.join(workspace_new, exec_filename),
                          "w",
                      ) as f:
                          f.write(script_text)
  
              experiments.append(
                  create_experiment(
                      filename=exec_filename,
                      args=other_args,
                      experiment_name=experiment_name,
                      project=project,
                      artifacts=current_artifacts,
                      resources_needed=resources_needed,
                      metric=runner_args.metric,
                      max_duration=runner_args.max_duration,
                      dependency_policy=StudioDependencyPolicy(),
                  )
              )
          return experiments
  
      if optimizer is not None:
          experiments = create_experiments(hyperparam_tuples)
      else:
          h = HyperparameterParser(runner_args, logger)
          hyperparam_tuples = h.convert_to_tuples(h.parse())
          experiments = create_experiments(hyperparam_tuples)
  
      return experiments
  
imports: import copy
  import sys
  import argparse
  import re
  import os
  import uuid
  import importlib
  import time
  import six
  import numpy
  from studio.credentials.credentials import KEY_CREDENTIALS
  from studio.hyperparameter import HyperparameterParser
  from studio.extra_util import Progbar, rsync_cp
  from studio.experiments.experiment import create_experiment
  from studio.experiment_submitter import submit_experiments
  from studio import model
  from studio import git_util
  from studio import local_worker
  from studio import fs_tracker
  from studio.dependencies_policies.studio_dependencies_policy import StudioDependencyPolicy
  from studio.util import logs, util
label_desc: Use image node_id 8 for calling a global function with example usage: _add_hyperparam_experiments(exec_filename, other_args, runner_args, artifacts, resources_needed, logger, optimizer, hyperparam_tuples) and returns: experiments, experiments