code: def random_search_optimizer(
      model: GenericDeterministicModel,
      bounds: Tensor,
      num_points: int,
      maximize: bool,
      pop_size: int = 1024,
      max_tries: int = 10,
  ) -> Tuple[Tensor, Tensor]:
      r"""Optimize a function via random search.
  
      Args:
          model: The model.
          bounds: A `2 x d`-dim Tensor containing the input bounds.
          num_points: The number of optimal points to be outputted.
          maximize: If true, we consider a maximization problem.
          pop_size: The number of function evaluations per try.
          max_tries: The maximum number of tries.
  
      Returns:
          A two-element tuple containing
  
          - A `num_points x d`-dim Tensor containing the collection of optimal inputs.
          - A `num_points x M`-dim Tensor containing the collection of optimal
              objectives.
      """
      tkwargs = {"dtype": bounds.dtype, "device": bounds.device}
      weight = 1.0 if maximize else -1.0
      optimal_inputs = torch.tensor([], **tkwargs)
      optimal_outputs = torch.tensor([], **tkwargs)
      num_tries = 0
      ratio = 2
      while ratio > 1 and num_tries < max_tries:
          X = draw_sobol_samples(
              bounds=bounds, n=pop_size, q=1
          ).squeeze(-2)
          Y = model.posterior(X).mean
          X_aug = torch.cat([optimal_inputs, X], dim=0)
          Y_aug = torch.cat([optimal_outputs, Y], dim=0)
          pareto_mask = is_non_dominated(weight * Y_aug)
          optimal_inputs = X_aug[pareto_mask]
          optimal_outputs = Y_aug[pareto_mask]
          num_found = len(optimal_inputs)
          ratio = ceil(num_points / num_found)
          num_tries = num_tries + 1
      # If maximum number of retries exceeded throw out a runtime error.
      if ratio > 1:
          error_text = f"Only found {num_found} optimal points instead of {num_points}."
          raise RuntimeError(error_text)
      else:
          return (
              optimal_inputs[:num_points],
              optimal_outputs[:num_points],
          )
  
imports: from __future__ import annotations
  import math
  import warnings
  from math import ceil
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import torch
  from botorch.acquisition import monte_carlo
  from botorch.acquisition.multi_objective.objective import IdentityMCMultiOutputObjective, MCMultiOutputObjective
  from botorch.exceptions.errors import UnsupportedError
  from botorch.exceptions.warnings import BotorchWarning
  from botorch.models.deterministic import GenericDeterministicModel
  from botorch.models.fully_bayesian import MCMC_DIM
  from botorch.models.model import Model
  from botorch.sampling.get_sampler import get_sampler
  from botorch.utils.gp_sampling import get_gp_samples
  from botorch.utils.multi_objective.box_decompositions.box_decomposition import BoxDecomposition
  from botorch.utils.multi_objective.box_decompositions.box_decomposition_list import BoxDecompositionList
  from botorch.utils.multi_objective.box_decompositions.dominated import DominatedPartitioning
  from botorch.utils.multi_objective.pareto import is_non_dominated
  from botorch.utils.objective import compute_feasibility_indicator
  from botorch.utils.sampling import draw_sobol_samples
  from botorch.utils.transforms import is_ensemble
  from torch import Tensor
label_desc: Use image node_id 4 for calling a global function with example usage: random_search_optimizer(model, bounds, num_points, maximize, pop_size, max_tries) and returns: optimal_inputs,  optimal_outputs