code: def apply_constraints(
      obj: Tensor,
      constraints: List[Callable[[Tensor], Tensor]],
      samples: Tensor,
      infeasible_cost: float,
      eta: Union[Tensor, float] = 1e-3,
  ) -> Tensor:
      r"""Apply constraints using an infeasible_cost `M` for negative objectives.
  
      This allows feasibility-weighting an objective for the case where the
      objective can be negative by using the following strategy:
      (1) Add `M` to make obj non-negative;
      (2) Apply constraints using the sigmoid approximation;
      (3) Shift by `-M`.
  
      Args:
          obj: A `n_samples x b x q (x m')`-dim Tensor of objective values.
          constraints: A list of callables, each mapping a Tensor of size `b x q x m`
              to a Tensor of size `b x q`, where negative values imply feasibility.
              This callable must support broadcasting. Only relevant for multi-
              output models (`m` > 1).
          samples: A `n_samples x b x q x m` Tensor of samples drawn from the posterior.
          infeasible_cost: The infeasible value.
          eta: The temperature parameter of the sigmoid function. Can be either a float
              or a 1-dim tensor. In case of a float the same eta is used for every
              constraint in constraints. In case of a tensor the length of the tensor
              must match the number of provided constraints. The i-th constraint is
              then estimated with the i-th eta value.
  
      Returns:
          A `n_samples x b x q (x m')`-dim tensor of feasibility-weighted objectives.
      """
      # obj has dimensions n_samples x b x q (x m')
      obj = obj.add(infeasible_cost)  # now it is nonnegative
      obj = apply_constraints_nonnegative_soft(
          obj=obj,
          constraints=constraints,
          samples=samples,
          eta=eta,
      )
      return obj.add(-infeasible_cost)
  
file_path: botorch/botorch/utils/objective.py
imports: from __future__ import annotations
  import warnings
  from typing import Callable, List, Optional, Union
  import torch
  from botorch.utils.safe_math import log_fatmoid, logexpit
  from botorch.utils.transforms import normalize_indices
  from torch import Tensor
label_desc: Use image node_id 6 for calling a global function with example usage: apply_constraints(obj, constraints, samples, infeasible_cost, eta) and returns: obj