code: def _get_model_per_metric(
      model: Union[BotorchModel, ModularBoTorchModel],
      metrics: List[str],
  ) -> List[Model]:
      """For a given TorchModel model, returns a list of botorch.models.model.Model
      objects corresponding to - and in the same order as - the given metrics.
      """
      if isinstance(model, BotorchModel):
          # guaranteed not to be None after accessing search_space_digest
          gp_model = model.model
          model_idx = [model.metric_names.index(m) for m in metrics]
          if not isinstance(gp_model, ModelList):
              if (
                  gp_model.num_outputs == 1
              ):  # can accept single output models
                  return [gp_model for _ in model_idx]
              raise NotImplementedError(
                  f"type(model_bridge.model.model) = {type(gp_model)}, "
                  "but only ModelList is supported."
              )
          return [gp_model.models[i] for i in model_idx]
      else:  # isinstance(model, ModularBoTorchModel):
          model_list = []
          for (
              m
          ) in (
              metrics
          ):  # for each metric, find a corresponding surrogate
              for (
                  label,
                  outcomes,
              ) in model.outcomes_by_surrogate_label.items():
                  if m in outcomes:
                      i = outcomes.index(m)
                      metric_model = model.surrogates[label].model
                      # since model is a ModularBoTorchModel, metric_model will be a
                      # `botorch.models.model.Model` object, which have the `num_outputs`
                      # property and `subset_outputs` method.
                      if (
                          metric_model.num_outputs > 1
                      ):  # subset to relevant output
                          metric_model = metric_model.subset_output([i])
                      model_list.append(metric_model)
                      continue  # found surrogate for `m`, so we can move on to next `m`.
          return model_list
  
imports: from copy import deepcopy
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  import torch
  from ax.modelbridge.torch import TorchModelBridge
  from ax.models.torch.botorch import BotorchModel
  from ax.models.torch.botorch_modular.model import BoTorchModel
  from ax.utils.common.typeutils import checked_cast
  from botorch.models.model import Model, ModelList
  from botorch.posteriors.gpytorch import GPyTorchPosterior
  from botorch.sampling.normal import SobolQMCNormalSampler
  from botorch.utils.sampling import draw_sobol_samples
  from botorch.utils.transforms import unnormalize
  from torch import Tensor
label_desc: Use image node_id 6 for calling a global function with example usage: _get_model_per_metric(model, metrics) and returns: unknown, model_list, unknown