code: def maximise_with_method_on_product_euclidean_spaces(
      method,
      obj,
      list_of_euc_domains,
      max_evals,
      return_history=False,
      *args,
      **kwargs,
  ):
      """Maximises an objective with method on a product Euclidean space."""
  
      def _regroup_flattended_point(pt, _dom_dims, _cum_dims):
          """Regroups a flattened point into a list of lists."""
          ret = [
              pt[cd : cd + d] for (cd, d) in zip(_cum_dims, _dom_dims)
          ]
          assert len(ret) == len(
              _dom_dims
          )  # Check if dimensions match.
          return ret
  
      dom_dims = [dom.dim for dom in list_of_euc_domains]
      cum_dims = list(np.cumsum(dom_dims))
      cum_dims = [0] + cum_dims[:-1]
      euc_dom_bounds = flatten_list_of_lists(
          [dom.bounds for dom in list_of_euc_domains]
      )
      modified_obj = lambda x: obj(
          _regroup_flattended_point(x, dom_dims, cum_dims)
      )
      opt_result = maximise_with_method_on_euclidean_domain(
          method,
          modified_obj,
          euc_dom_bounds,
          max_evals,
          return_history,
          *args,
          **kwargs,
      )
      if return_history:
          max_val, max_pt, history = opt_result
      else:
          max_val, max_pt = opt_result
      # regroup the maximum point
      regrouped_max_pt = _regroup_flattended_point(
          max_pt, dom_dims, cum_dims
      )
      if return_history:
          return max_val, regrouped_max_pt, history
      else:
          return max_val, regrouped_max_pt
  
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 14 for calling a global function with example usage: maximise_with_method_on_product_euclidean_spaces(method, obj, list_of_euc_domains, max_evals, return_history) and returns: ret, max_val,  regrouped_max_pt,  history, max_val,  regrouped_max_pt