code: def maximise_with_method(
      method,
      obj,
      domain,
      max_evals,
      return_history=False,
      *args,
      **kwargs,
  ):
      """A wrapper which optimises obj over the domain domain."""
      # If the method itself is a function, just use it.
      if hasattr(method, "__call__"):
          return method(
              obj, domain, max_evals, return_history, *args, **kwargs
          )
      # The common use case is that the method is a string.
      if domain.get_type() == "euclidean":
          return maximise_with_method_on_euclidean_domain(
              method,
              obj,
              domain.bounds,
              max_evals,
              return_history,
              *args,
              **kwargs,
          )
      elif domain.get_type() == "integral":
          return maximise_with_method_on_integral_domain(
              method,
              obj,
              domain.bounds,
              max_evals,
              domain.get_dim(),
              return_history,
              *args,
              **kwargs,
          )
      elif domain.get_type() == "prod_discrete":
          return maximise_with_method_on_prod_discrete_domain(
              method,
              obj,
              domain,
              max_evals,
              return_history,
              *args,
              **kwargs,
          )
      elif domain.get_type() == "cartesian_product":
          return maximise_with_method_on_cp_domain(
              method,
              obj,
              domain,
              max_evals,
              return_history,
              *args,
              **kwargs,
          )
      else:
          raise ValueError(
              "Unknown domain type %s." % (domain.get_type())
          )
  
imports: from argparse import Namespace
  import numpy
  from .cp_domain_utils import get_processed_from_raw_via_config, get_raw_from_processed_via_config, sample_from_cp_domain
  from ..utils.general_utils import map_to_bounds, flatten_list_of_lists
  from ..utils.oper_utils import direct_ft_maximise, latin_hc_sampling, pdoo_maximise, random_maximise
label_desc: Use image node_id 10 for calling a global function with example usage: maximise_with_method(method, obj, domain, max_evals, return_history) and returns: method, maximise_with_method_on_euclidean_domain, maximise_with_method_on_integral_domain, maximise_with_method_on_prod_discrete_domain, maximise_with_method_on_cp_domain