code: def get_infeasible_cost(
      X: Tensor,
      model: Model,
      objective: Optional[
          Callable[[Tensor, Optional[Tensor]], Tensor]
      ] = None,
      posterior_transform: Optional[PosteriorTransform] = None,
  ) -> Tensor:
      r"""Get infeasible cost for a model and objective.
  
      For each outcome, computes an infeasible cost `M` such that
      `-M < min_x f(x)` almost always, so that feasible points are preferred.
  
      Args:
          X: A `n x d` Tensor of `n` design points to use in evaluating the
              minimum. These points should cover the design space well. The more
              points the better the estimate, at the expense of added computation.
          model: A fitted botorch model with `m` outcomes.
          objective: The objective with which to evaluate the model output.
          posterior_transform: A PosteriorTransform (optional).
  
      Returns:
          An `m`-dim tensor of infeasible cost values.
  
      Example:
          >>> model = SingleTaskGP(train_X, train_Y)
          >>> objective = lambda Y: Y[..., -1] ** 2
          >>> M = get_infeasible_cost(train_X, model, obj)
      """
      if objective is None:
  
          def objective(Y: Tensor, X: Optional[Tensor] = None):
              return Y.squeeze(-1)
  
      posterior = model.posterior(
          X, posterior_transform=posterior_transform
      )
      lb = objective(
          posterior.mean - 6 * posterior.variance.clamp_min(0).sqrt(),
          X=X,
      )
      if lb.ndim < posterior.mean.ndim:
          lb = lb.unsqueeze(-1)
      # Take outcome-wise min. Looping in to handle batched models.
      while lb.dim() > 1:
          lb = lb.min(dim=-2).values
      return -(lb.clamp_max(0.0))
  
imports: from __future__ import annotations
  import math
  from typing import Callable, Dict, List, Optional, Tuple
  import torch
  from botorch.acquisition.objective import IdentityMCObjective, MCAcquisitionObjective, PosteriorTransform
  from botorch.exceptions.errors import BotorchTensorDimensionError, DeprecationError, UnsupportedError
  from botorch.models.fully_bayesian import MCMC_DIM
  from botorch.models.model import Model
  from botorch.sampling.base import MCSampler
  from botorch.sampling.get_sampler import get_sampler
  from botorch.sampling.pathwise import draw_matheron_paths
  from botorch.utils.objective import compute_feasibility_indicator
  from botorch.utils.sampling import optimize_posterior_samples
  from botorch.utils.transforms import is_ensemble, normalize_indices
  from torch import Tensor
label_desc: Use image node_id 5 for calling a global function with example usage: get_infeasible_cost(X, model, objective, posterior_transform) and returns: unknown, Y