code: def get_MTGP_LEGACY(
      experiment: Experiment,
      data: Data,
      search_space: Optional[SearchSpace] = None,
      trial_index: Optional[int] = None,
      device: torch.device = DEFAULT_TORCH_DEVICE,
      dtype: torch.dtype = torch.double,
  ) -> TorchModelBridge:
      """Instantiates a Multi-task Gaussian Process (MTGP) model that generates
      points with EI.
  
      If the input experiment is a MultiTypeExperiment then a
      Multi-type Multi-task GP model will be instantiated.
      Otherwise, the model will be a Single-type Multi-task GP.
      """
  
      if isinstance(experiment, MultiTypeExperiment):
          trial_index_to_type = {
              t.index: t.trial_type for t in experiment.trials.values()
          }
          transforms = MT_MTGP_trans
          transform_configs = {
              "TrialAsTask": {
                  "trial_level_map": {"trial_type": trial_index_to_type}
              },
              "ConvertMetricNames": tconfig_from_mt_experiment(
                  experiment
              ),
          }
      else:
          # Set transforms for a Single-type MTGP model.
          transforms = ST_MTGP_trans
          transform_configs = None
  
      # Choose the status quo features for the experiment from the selected trial.
      # If trial_index is None, we will look for a status quo from the last
      # experiment trial to use as a status quo for the experiment.
      if trial_index is None:
          trial_index = len(experiment.trials) - 1
      elif trial_index >= len(experiment.trials):
          raise ValueError(
              "trial_index is bigger than the number of experiment trials"
          )
  
      # pyre-fixme[16]: `ax.core.base_trial.BaseTrial` has no attribute `status_quo`.
      status_quo = experiment.trials[trial_index].status_quo
      if status_quo is None:
          status_quo_features = None
      else:
          status_quo_features = ObservationFeatures(
              parameters=status_quo.parameters,
              trial_index=trial_index,
          )
  
      return TorchModelBridge(
          experiment=experiment,
          search_space=search_space or experiment.search_space,
          data=data,
          model=BotorchModel(),
          transforms=transforms,
          # pyre-fixme[6]: Expected `Optional[Dict[str, Dict[str,
          #  typing.Union[botorch.acquisition.acquisition.AcquisitionFunction, float,
          #  int, str]]]]` for 6th param but got `Optional[Dict[str,
          #  typing.Union[Dict[str, Dict[str, Dict[int, Optional[str]]]], Dict[str,
          #  typing.Union[botorch.acquisition.acquisition.AcquisitionFunction, float,
          #  int, str]]]]]`.
          transform_configs=transform_configs,
          torch_dtype=dtype,
          torch_device=device,
          status_quo_features=status_quo_features,
      )
  
imports: from logging import Logger
  from typing import Any, Dict, List, Optional, Type
  import torch
  from ax.core.data import Data
  from ax.core.experiment import Experiment
  from ax.core.multi_type_experiment import MultiTypeExperiment
  from ax.core.observation import ObservationFeatures
  from ax.core.optimization_config import OptimizationConfig
  from ax.core.search_space import SearchSpace
  from ax.modelbridge.discrete import DiscreteModelBridge
  from ax.modelbridge.modelbridge_utils import check_has_multi_objective_and_data
  from ax.modelbridge.random import RandomModelBridge
  from ax.modelbridge.registry import Cont_X_trans, Models, MT_MTGP_trans, ST_MTGP_trans, Y_trans
  from ax.modelbridge.torch import TorchModelBridge
  from ax.modelbridge.transforms.base import Transform
  from ax.modelbridge.transforms.convert_metric_names import tconfig_from_mt_experiment
  from ax.models.torch.botorch import BotorchModel, TAcqfConstructor, TModelConstructor, TModelPredictor, TOptimizer
  from ax.models.torch.botorch_defaults import get_and_fit_model, get_qLogNEI, scipy_optimizer
  from ax.models.torch.botorch_moo_defaults import get_EHVI
  from ax.models.torch.utils import predict_from_model
  from ax.models.types import TConfig
  from ax.utils.common.logger import get_logger
  from ax.utils.common.typeutils import checked_cast
label_desc: Use image node_id 8 for calling a global function with example usage: get_MTGP_LEGACY(experiment, data, search_space, trial_index, device, dtype) and returns: TorchModelBridge