code: def test_apply_constraints_multi_output(self):
      # nonnegative objective, one constraint
      tkwargs = {"device": self.device}
      for dtype in (torch.float, torch.double):
          tkwargs["dtype"] = dtype
          samples = torch.rand(3, 2, **tkwargs)
          obj = samples.clone()
          obj = apply_constraints(
              obj=obj,
              constraints=[zeros_f],
              samples=samples,
              infeasible_cost=0.0,
          )
          self.assertTrue(torch.equal(obj, samples * 0.5))
          # nonnegative objective, two constraint
          obj = samples.clone()
          obj = apply_constraints(
              obj=obj,
              constraints=[zeros_f, zeros_f],
              samples=samples,
              infeasible_cost=0.0,
          )
          self.assertTrue(torch.equal(obj, samples * 0.5 * 0.5))
          # nonnegative objective, two constraint explicit eta
          obj = samples.clone()
          obj = apply_constraints(
              obj=obj,
              constraints=[zeros_f, zeros_f],
              samples=samples,
              infeasible_cost=0.0,
              eta=torch.tensor([10e-3, 10e-3]).to(**tkwargs),
          )
          self.assertTrue(torch.equal(obj, samples * 0.5 * 0.5))
          # nonnegative objective, two constraint explicit different eta
          obj = samples.clone()
          obj = apply_constraints(
              obj=obj,
              constraints=[nonzeros_f, nonzeros_f],
              samples=samples,
              infeasible_cost=0.0,
              eta=torch.tensor([10e-1, 10e-2]).to(**tkwargs),
          )
          self.assertTrue(
              torch.allclose(
                  obj,
                  samples
                  * torch.sigmoid(torch.as_tensor(-0.1) / 10e-1)
                  * torch.sigmoid(torch.as_tensor(-0.1) / 10e-2),
              )
          )
          # nonnegative objective, two constraint explicit different eta
          # use ones_f
          obj = samples.clone()
          obj = apply_constraints(
              obj=obj,
              constraints=[ones_f, ones_f],
              samples=samples,
              infeasible_cost=0.0,
              eta=torch.tensor([1, 10]).to(**tkwargs),
          )
          self.assertTrue(
              torch.allclose(
                  obj,
                  samples
                  * torch.sigmoid(torch.as_tensor(-1.0) / 1.0)
                  * torch.sigmoid(torch.as_tensor(-1.0) / 10.0),
              )
          )
          # negative objective, one constraint, infeasible_cost
          obj = samples.clone().clamp_min(-1.0)
          obj = apply_constraints(
              obj=obj,
              constraints=[zeros_f],
              samples=samples,
              infeasible_cost=2.0,
          )
          self.assertAllClose(obj, samples.clamp_min(-1.0) * 0.5 - 1.0)
          # negative objective, one constraint, infeasible_cost, explicit eta
          obj = samples.clone().clamp_min(-1.0)
          obj = apply_constraints(
              obj=obj,
              constraints=[zeros_f],
              samples=samples,
              infeasible_cost=2.0,
              eta=torch.tensor([10e-3]).to(**tkwargs),
          )
          self.assertAllClose(obj, samples.clamp_min(-1.0) * 0.5 - 1.0)
          # nonnegative objective, one constraint, eta = 0
          obj = samples
          with self.assertRaisesRegex(
              ValueError, "eta must be positive"
          ):
              apply_constraints(
                  obj=obj,
                  constraints=[zeros_f],
                  samples=samples,
                  infeasible_cost=0.0,
                  eta=0.0,
              )
  
imports: import torch
  from botorch.utils import apply_constraints, get_objective_weights_transform
  from botorch.utils.objective import compute_feasibility_indicator, compute_smoothed_feasibility_indicator, soft_eval_constraint
  from botorch.utils.testing import BotorchTestCase
  from torch import Tensor
label_desc: Use image node_id 2 for calling the TestApplyConstraints obj's underlying member method code with example usage: obj.test_apply_constraints_multi_output() without return types