code: def test_box_decomposition(self) -> None:
      with self.assertRaises(TypeError):
          BoxDecomposition()
      for dtype, m, sort in product(
          (torch.float, torch.double), (2, 3), (True, False)
      ):
          with mock.patch.object(
              DummyBoxDecomposition,
              "_partition_space_2d" if m == 2 else "_partition_space",
          ) as mock_partition_space:
              ref_point = self.ref_point_raw[:m].to(dtype=dtype)
              Y = self.Y_raw[:, :m].to(dtype=dtype)
              pareto_Y = self.pareto_Y_raw[:, :m].to(dtype=dtype)
              bd = DummyBoxDecomposition(ref_point=ref_point, sort=sort)
  
              # test pareto_Y before it is initialized
              with self.assertRaises(BotorchError):
                  bd.pareto_Y
              bd = DummyBoxDecomposition(
                  ref_point=ref_point, sort=sort, Y=Y
              )
  
              mock_partition_space.assert_called_once()
              # test attributes
              expected_pareto_Y = (
                  pareto_Y[torch.argsort(-pareto_Y[:, 0])]
                  if sort
                  else pareto_Y
              )
              self.assertTrue(
                  torch.equal(bd.pareto_Y, expected_pareto_Y)
              )
              self.assertTrue(torch.equal(bd.Y, Y))
              self.assertTrue(torch.equal(bd._neg_Y, -Y))
              self.assertTrue(
                  torch.equal(bd._neg_pareto_Y, -expected_pareto_Y)
              )
              self.assertTrue(torch.equal(bd.ref_point, ref_point))
              self.assertTrue(
                  torch.equal(bd._neg_ref_point, -ref_point)
              )
              self.assertEqual(bd.num_outcomes, m)
  
              # test empty Y
              bd = DummyBoxDecomposition(
                  ref_point=ref_point, sort=sort, Y=Y[:0]
              )
              self.assertTrue(
                  torch.equal(bd.pareto_Y, expected_pareto_Y[:0])
              )
  
              # test _update_neg_Y
              bd = DummyBoxDecomposition(ref_point=ref_point, sort=sort)
              bd._update_neg_Y(Y[:2])
              self.assertTrue(torch.equal(bd._neg_Y, -Y[:2]))
              bd._update_neg_Y(Y[2:])
              self.assertTrue(torch.equal(bd._neg_Y, -Y))
  
              # test batch mode
              if m == 2:
                  batch_Y = torch.stack([Y, Y + 1], dim=0)
                  bd = DummyBoxDecomposition(
                      ref_point=ref_point, sort=sort, Y=batch_Y
                  )
                  batch_expected_pareto_Y = torch.stack(
                      [expected_pareto_Y, expected_pareto_Y + 1], dim=0
                  )
                  self.assertTrue(
                      torch.equal(bd.pareto_Y, batch_expected_pareto_Y)
                  )
                  self.assertTrue(torch.equal(bd.Y, batch_Y))
                  self.assertTrue(torch.equal(bd.ref_point, ref_point))
                  # test batch ref point
                  batch_ref_point = torch.stack(
                      [ref_point, ref_point + 1], dim=0
                  )
                  bd = DummyBoxDecomposition(
                      ref_point=batch_ref_point, sort=sort, Y=batch_Y
                  )
                  self.assertTrue(
                      torch.equal(bd.ref_point, batch_ref_point)
                  )
                  # test multiple batch dims
                  with self.assertRaises(NotImplementedError):
                      DummyBoxDecomposition(
                          ref_point=ref_point,
                          sort=sort,
                          Y=batch_Y.unsqueeze(0),
                      )
                  # test empty Y
                  bd = DummyBoxDecomposition(
                      ref_point=ref_point, sort=sort, Y=batch_Y[:, :0]
                  )
                  self.assertTrue(
                      torch.equal(
                          bd.pareto_Y, batch_expected_pareto_Y[:, :0]
                      )
                  )
  
                  # test padded pareto frontiers with different numbers of
                  # points
                  batch_Y[1, 1] = batch_Y[1, 0] - 1
                  batch_Y[1, 2] = batch_Y[1, 0] - 2
                  bd = DummyBoxDecomposition(
                      ref_point=ref_point, sort=sort, Y=batch_Y
                  )
                  batch_expected_pareto_Y = torch.stack(
                      [
                          expected_pareto_Y,
                          batch_Y[1, :1].expand(
                              expected_pareto_Y.shape
                          ),
                      ],
                      dim=0,
                  )
                  self.assertTrue(
                      torch.equal(bd.pareto_Y, batch_expected_pareto_Y)
                  )
                  self.assertTrue(torch.equal(bd.Y, batch_Y))
  
              else:
                  with self.assertRaises(NotImplementedError):
                      DummyBoxDecomposition(
                          ref_point=ref_point,
                          sort=sort,
                          Y=Y.unsqueeze(0),
                      )
  
imports: from __future__ import annotations
  from itertools import product
  from unittest import mock
  import torch
  from botorch.exceptions.errors import BotorchError
  from botorch.utils.multi_objective.box_decompositions.box_decomposition import BoxDecomposition, FastPartitioning
  from botorch.utils.multi_objective.box_decompositions.dominated import DominatedPartitioning
  from botorch.utils.multi_objective.box_decompositions.non_dominated import FastNondominatedPartitioning, NondominatedPartitioning
  from botorch.utils.multi_objective.box_decompositions.utils import update_local_upper_bounds_incremental
  from botorch.utils.testing import BotorchTestCase
label_desc: Use image node_id 2 for calling the TestBoxDecomposition obj's underlying member method code with example usage: obj.test_box_decomposition() without return types