code: def preprocess_multifidelity_arguments(
      fidel_space, domain, funcs, fidel_cost_func, fidel_to_opt, config
  ):
      """Preprocess fidel_space, domain arguments and configuration file."""
      # Preprocess config argument
      converted_cp_to_euclidean = False
      if isinstance(config, str):
          config = load_config_file(config)
      if fidel_space is None:
          fidel_space = config.fidel_space
      if domain is None:
          domain = config.domain
      if fidel_to_opt is None:
          fidel_to_opt = config.fidel_to_opt
      # The function
      if config is not None:
          proc_funcs = [
              get_processed_func_from_raw_func_for_cp_domain_fidelity(
                  f, config
              )
              for f in funcs
          ]
          proc_fidel_cost_func = (
              get_processed_func_from_raw_func_for_cp_domain(
                  fidel_cost_func,
                  config.fidel_space,
                  config.fidel_space_orderings.index_ordering,
                  config.fidel_space_orderings.dim_ordering,
              )
          )
      else:
          proc_funcs = funcs
          proc_fidel_cost_func = fidel_cost_func
      ret_funcs = proc_funcs
      ret_fidel_cost_func = proc_fidel_cost_func
      # Preprocess domain argument
      if isinstance(fidel_space, (list, tuple)) and isinstance(
          domain, (list, tuple)
      ):
          domain = EuclideanDomain(domain)
          fidel_space = EuclideanDomain(fidel_space)
      elif (
          fidel_space.get_type() == "euclidean"
          and domain.get_type() == "euclidean"
      ):
          pass
      elif (
          fidel_space.get_type() == "cartesian_product"
          and domain.get_type() == "cartesian_product"
      ):
          if (
              fidel_space.num_domains == 1
              and fidel_space.list_of_domains[0].get_type()
              == "euclidean"
              and (
                  (not hasattr(fidel_space, "domain_constraints"))
                  or fidel_space.domain_constraints is None
              )
              and domain.num_domains == 1
              and domain.list_of_domains[0].get_type() == "euclidean"
              and (
                  (not hasattr(domain, "domain_constraints"))
                  or domain.domain_constraints is None
              )
          ):
              # Change the fidelity space
              fidel_space = fidel_space.list_of_domains[0]
              config.fidel_space_orderings.dim_ordering = (
                  config.fidel_space_orderings.dim_ordering[0]
              )
              config.fidel_space_orderings.index_ordering = (
                  config.fidel_space_orderings.index_ordering[0]
              )
              config.fidel_space_orderings.kernel_ordering = (
                  config.fidel_space_orderings.kernel_ordering[0]
              )
              config.fidel_space_orderings.name_ordering = (
                  config.fidel_space_orderings.name_ordering[0]
              )
              config.fidel_to_opt = config.fidel_to_opt[0]
              fidel_to_opt = fidel_to_opt[0]
              # Change the domain
              domain = domain.list_of_domains[0]
              config.domain_orderings.dim_ordering = (
                  config.domain_orderings.dim_ordering[0]
              )
              config.domain_orderings.index_ordering = (
                  config.domain_orderings.index_ordering[0]
              )
              config.domain_orderings.kernel_ordering = (
                  config.domain_orderings.kernel_ordering[0]
              )
              config.domain_orderings.name_ordering = (
                  config.domain_orderings.name_ordering[0]
              )
              # Add to config
              config.fidel_space = fidel_space
              config.domain = domain
              converted_cp_to_euclidean = True
  
              # Functions
              def _get_ret_func_from_proc_func_for_euc_domains(
                  _proc_func,
              ):
                  """Get function to return."""
                  return lambda z, x: _proc_func([z], [x])
  
              ret_funcs = [
                  _get_ret_func_from_proc_func_for_euc_domains(pf)
                  for pf in proc_funcs
              ]
              ret_fidel_cost_func = lambda z: proc_fidel_cost_func([z])
      else:
          raise ValueError(
              "fidel_space and domain should be either both instances of "
              + "EuclideanDomain or both CartesianProductDomain."
          )
      return (
          fidel_space,
          domain,
          ret_funcs,
          ret_fidel_cost_func,
          fidel_to_opt,
          config,
          converted_cp_to_euclidean,
      )
  
file_path: dragonfly/dragonfly/apis/api_utils.py
imports: from argparse import Namespace
  import numpy
  from ..exd.cp_domain_utils import load_config_file, get_processed_func_from_raw_func_for_cp_domain_fidelity, get_processed_func_from_raw_func_for_cp_domain
  from ..exd.domains import EuclideanDomain
  from ..exd.worker_manager import MultiProcessingWorkerManager, SyntheticWorkerManager, AbstractWorkerManager
  from ..opt.ga_optimiser import ga_opt_args
  from ..opt.gp_bandit import get_all_euc_gp_bandit_args, get_all_cp_gp_bandit_args, get_all_mf_euc_gp_bandit_args, get_all_mf_cp_gp_bandit_args
  from ..opt.random_optimiser import euclidean_random_optimiser_args, mf_euclidean_random_optimiser_args, cp_random_optimiser_args, mf_cp_random_optimiser_args
  from ..opt.multiobjective_gp_bandit import get_all_euc_moo_gp_bandit_args, get_all_cp_moo_gp_bandit_args
  from ..opt.random_multiobjective_optimiser import euclidean_random_multiobjective_optimiser_args, cp_random_multiobjective_optimiser_args
  from ..utils.general_utils import map_to_bounds
  from ..utils.option_handler import load_options
label_desc: Use image node_id 4 for calling a global function with example usage: preprocess_multifidelity_arguments(fidel_space, domain, funcs, fidel_cost_func, fidel_to_opt, config) and returns: fidel_space,  domain,  ret_funcs,  ret_fidel_cost_func,  fidel_to_opt,  config,  converted_cp_to_euclidean, function