code: def _get_torch_model(
      model_bridge: TorchModelBridge,
  ) -> Union[BotorchModel, ModularBoTorchModel]:
      """Returns the TorchModel of the model_bridge, if it is a type that stores
      SearchSpaceDigest during model fitting. At this point, this is BotorchModel, and
      ModularBoTorchModel.
      """
      if not isinstance(model_bridge, TorchModelBridge):
          raise NotImplementedError(
              f"{type(model_bridge) = }, but only TorchModelBridge is supported."
          )
      model = model_bridge.model  # should be of type TorchModel
      if not (
          isinstance(model, BotorchModel)
          or isinstance(model, ModularBoTorchModel)
      ):
          raise NotImplementedError(
              f"{type(model_bridge.model) = }, but only "
              "Union[BotorchModel, ModularBoTorchModel] is supported."
          )
      return model
  
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 5 for calling a global function with example usage: _get_torch_model(model_bridge) and returns: model