code: def _rand_maximise_vectorised_objective_in_cp_domain(
      obj, domain, max_evals, return_history=False
  ):
      """Maximises a vectorised function in Cartesian product spaces.
      Mostly used for TS style acquisitions in BO.
      """
      rand_samples = []
      num_sample_tries = 0
      while not (
          len(rand_samples) >= max_evals
          or (len(rand_samples) > 0 and num_sample_tries >= 5)
      ):
          rand_samples.extend(
              sample_from_cp_domain(
                  domain,
                  int(max_evals),
                  verbose_constraint_satisfaction=False,
              )
          )
          num_sample_tries += 1
          if len(rand_samples) == 0 and num_sample_tries % 10 == 0:
              from warnings import warn
  
              warn(
                  (
                      "Sampling from domain failed despite %d attempts -- will "
                      + "continue trying but consider reparametrising your domain if "
                      + "this problem persists."
                  )
                  % (num_sample_tries)
              )
      # Compute objective on sampled points.
      rand_values = [obj(x) for x in rand_samples]
      max_idx = np.argmax(rand_values)
      max_pt = rand_samples[max_idx]
      max_val = rand_values[max_idx]
      if return_history:
          history = Namespace(
              query_points=rand_samples, query_vals=rand_values
          )
          return max_val, max_pt, history
      else:
          return max_val, 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 15 for calling a global function with example usage: _rand_maximise_vectorised_objective_in_cp_domain(obj, domain, max_evals, return_history) and returns: max_val,  max_pt,  history, max_val,  max_pt