code: def copy_experiments() -> dict:
      """
      - copy experiments, keep id mapping
      - copy trials and all metrics and keep id mapping
      - update trials' experiment_id to the new experiment id
      """
      added_rows: Dict[str, int] = {}
      with db_cursor() as cur:
          with duplicate_table_rows(cur, "experiments") as added_exps:
              added_rows["experiments"] = added_exps
              if added_exps == 0:
                  return added_rows
              with _copy_trials(
                  cur, exclude_single_searcher=False
              ) as affected_rows:
                  added_rows.update(affected_rows)
                  """
                  tables
                  - experiments: id
                  - experiments_id_map: id, og_id
                  - trials: id
                  - trials_id_map: id, og_id
                  """
                  # update new trials' experiment_id to the newly added experiment id
                  query = """
  UPDATE trials
  SET experiment_id = sub.new_exp_id
  FROM (
      SELECT trials.id as trial_id, experiments_id_map.id AS new_exp_id
      FROM trials
      JOIN trials_id_map ON trials.id = trials_id_map.id
      JOIN experiments_id_map ON trials.experiment_id = experiments_id_map.og_id
  ) as sub
  WHERE trials.id = sub.trial_id;
  """
                  cur.execute(query)
          cur.execute("COMMIT")
      return added_rows
  
file_path: determined/tools/scripts/replicate-metrics.py
imports: import concurrent.futures
  import contextlib
  import os
  import time
  from typing import Any, Dict, Generator, List, Set, Tuple, Union
  import psycopg
  from psycopg import sql
label_desc: Use image node_id 9 for calling a global function with example usage: copy_experiments() and returns: added_rows, added_rows