code: def _prepare_import(
      src_storage,
      dst_storage,
      experiments,
      resolve=None,
      import_benchmarks=True,
      progress_callback=None,
  ):
      """Prepare importation.
  
      Compute all changes to apply to make import and return changes as dictionaries.
  
      Parameters
      ----------
      src_storage: BaseStorageProtocol
          storage to import from
      dst_storage: BaseStorageProtocol
          storage to import into
      experiments:
          experiments to import from src_storage into dst_storage
      resolve:
          resolve policy
      import_benchmarks:
          if True, benchmarks will be also imported from src_database
      progress_callback:
          See :func:`load_database`
  
      Returns
      -------
      A couple (queries to delete, data to add) representing
      changes to apply to dst_storage to make import
      """
      assert resolve is None or resolve in (
          "ignore",
          "overwrite",
          "bump",
      )
  
      queries_to_delete = {}
      data_to_add = {}
  
      if import_benchmarks:
          src_benchmarks = src_storage.fetch_benchmark({})
          for i, src_benchmark in enumerate(src_benchmarks):
              _describe_import_progress(
                  STEP_CHECK_BENCHMARKS,
                  i,
                  len(src_benchmarks),
                  progress_callback,
              )
              dst_benchmarks = dst_storage.fetch_benchmark(
                  {"name": src_benchmark["name"]}
              )
              if dst_benchmarks:
                  (dst_benchmark,) = dst_benchmarks
                  if resolve == "ignore":
                      logger.info(
                          f'Ignored benchmark already in dst: {src_benchmark["name"]}'
                      )
                      continue
                  if resolve == "overwrite":
                      logger.info(
                          f'Overwrite benchmark in dst, name: {src_benchmark["name"]}'
                      )
                      queries_to_delete.setdefault(
                          COL_BENCHMARKS, []
                      ).append({"_id": dst_benchmark["_id"]})
                  elif resolve == "bump":
                      raise DatabaseError(
                          "Can't bump benchmark version, "
                          "as benchmarks do not currently support versioning."
                      )
                  else:  # resolve is None or unknown
                      raise DatabaseError(
                          f"Conflict detected without strategy to resolve ({resolve}) "
                          f"for benchmark {src_benchmark['name']}"
                      )
              # Delete benchmark database ID so that a new one will be generated on insertion
              del src_benchmark["_id"]
              data_to_add.setdefault(COL_BENCHMARKS, []).append(
                  src_benchmark
              )
          _describe_import_progress(
              STEP_CHECK_BENCHMARKS,
              len(src_benchmarks),
              len(src_benchmarks),
              progress_callback,
          )
  
      _describe_import_progress(
          STEP_CHECK_DST_EXPERIMENTS, 0, 1, progress_callback
      )
      all_dst_experiments = dst_storage.fetch_experiments({})
      # Dictionary mapping dst exp name to exp version to list of exps with same name and version
      dst_exp_map = {}
      last_versions = {}
      for dst_exp in all_dst_experiments:
          name = dst_exp["name"]
          version = dst_exp["version"]
          last_versions[name] = max(last_versions.get(name, 0), version)
          dst_exp_map.setdefault(name, {}).setdefault(
              version, []
          ).append(dst_exp)
      _describe_import_progress(
          STEP_CHECK_DST_EXPERIMENTS, 1, 1, progress_callback
      )
  
      if len(experiments) == 1:
          # As we load only 1 experiment, remove parent links if exist
          (exp_data,) = experiments
          if exp_data["refers"]:
              if exp_data["refers"]["root_id"] is not None:
                  logger.info(
                      "Removing reference to root experiment before loading"
                  )
                  exp_data["refers"]["root_id"] = None
              if exp_data["refers"]["parent_id"] is not None:
                  logger.info(
                      "Removing reference to parent experiment before loading"
                  )
                  exp_data["refers"]["parent_id"] = None
      else:
          # Load experiments ordered from parents to children,
          # so that we can get new parent IDs from dst
          # before writing children.
          graph = get_experiment_parent_links(experiments)
          experiments = graph.get_sorted_data()
  
      for i, experiment in enumerate(experiments):
          _describe_import_progress(
              STEP_CHECK_SRC_EXPERIMENTS,
              i,
              len(experiments),
              progress_callback,
          )
          dst_experiments = dst_exp_map.get(experiment["name"], {}).get(
              experiment["version"], []
          )
          if dst_experiments:
              (dst_experiment,) = dst_experiments
              if resolve == "ignore":
                  logger.info(
                      f"Ignored experiment already in dst: "
                      f'{experiment["name"]}.{experiment["version"]}'
                  )
                  continue
              if resolve == "overwrite":
                  # We must remove experiment data in dst
                  logger.info(
                      f"Overwrite experiment in dst: "
                      f'{dst_experiment["name"]}.{dst_experiment["version"]}'
                  )
                  for collection in EXPERIMENT_RELATED_COLLECTIONS:
                      queries_to_delete.setdefault(
                          collection, []
                      ).append({"experiment": dst_experiment["_id"]})
                  queries_to_delete.setdefault(
                      COL_EXPERIMENTS, []
                  ).append({"_id": dst_experiment["_id"]})
              elif resolve == "bump":
                  old_version = experiment["version"]
                  new_version = last_versions[experiment["name"]] + 1
                  last_versions[experiment["name"]] = new_version
                  experiment["version"] = new_version
                  logger.info(
                      f'Bumped version of src experiment: {experiment["name"]}, '
                      f"from {old_version} to {new_version}"
                  )
              else:  # resolve is None or unknown
                  raise DatabaseError(
                      f"Conflict detected without strategy to resolve ({resolve}) "
                      f"for experiment {experiment['name']}.{experiment['version']}"
                  )
          else:
              logger.info(
                  f'Import experiment {experiment["name"]}.{experiment["version"]}'
              )
  
          # Get data related to experiment to import.
          algo = src_storage.get_algorithm_lock_info(
              uid=experiment["_id"]
          )
          trials = src_storage.fetch_trials(uid=experiment["_id"])
          # We will use experiment key to link experiment to related data.
          exp_key = _get_exp_key(experiment)
          # Set data to add
          data_to_add.setdefault(COL_EXPERIMENTS, []).append(experiment)
          data_to_add.setdefault(COL_ALGOS, {})[exp_key] = algo
          data_to_add.setdefault(COL_TRIALS, {})[exp_key] = trials
      _describe_import_progress(
          STEP_CHECK_SRC_EXPERIMENTS,
          len(experiments),
          len(experiments),
          progress_callback,
      )
  
      return queries_to_delete, data_to_add
  
imports: import logging
  import os
  import shutil
  from typing import Any, Dict, List
  from orion.core.io.database import DatabaseError
  from orion.core.io.database.pickleddb import PickledDB
  from orion.core.utils import generate_temporary_file
  from orion.core.utils.tree import TreeNode
  from orion.storage.base import BaseStorageProtocol, setup_storage
label_desc: Use image node_id 5 for calling a global function with example usage: _prepare_import(src_storage, dst_storage, experiments, resolve, import_benchmarks, progress_callback) and returns: queries_to_delete,  data_to_add