code: def test_fast_partitioning(self):
      with self.assertRaises(TypeError):
          FastPartitioning()
      for dtype, m in product(
          (torch.float, torch.double),
          (2, 3),
      ):
          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)
          sort = m == 2
          expected_pareto_Y = (
              pareto_Y[torch.argsort(-pareto_Y[:, 0])]
              if sort
              else pareto_Y
          )
          bd = DummyFastPartitioning(ref_point=ref_point, Y=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 update
          bd = DummyFastPartitioning(ref_point=ref_point)
          with mock.patch.object(
              DummyFastPartitioning,
              "reset",
              wraps=bd.reset,
          ) as mock_reset:
              # with no existing neg_Y
              bd.update(Y=Y[:2])
              mock_reset.assert_called_once()
              # test with existing Y
              bd.update(Y=Y[2:])
              # check that reset is only called when m=2
              if m == 2:
                  mock_reset.assert_has_calls(
                      [mock.call(), mock.call()]
                  )
              else:
                  mock_reset.assert_called_once()
  
          # with existing neg_Y, and empty pareto_Y
          bd = DummyFastPartitioning(ref_point=ref_point, Y=Y[:0])
          with mock.patch.object(
              DummyFastPartitioning,
              "reset",
              wraps=bd.reset,
          ) as mock_reset:
              bd.update(Y=Y[0:])
              mock_reset.assert_called_once()
  
          # test empty pareto Y
          bd = DummyFastPartitioning(ref_point=ref_point)
          with mock.patch.object(
              DummyFastPartitioning,
              "_get_single_cell",
              wraps=bd._get_single_cell,
          ) as mock_get_single_cell:
              bd.update(Y=Y[:0])
              mock_get_single_cell.assert_called_once()
          # test batched empty pareto Y
          if m == 2:
              bd = DummyFastPartitioning(ref_point=ref_point)
              with mock.patch.object(
                  DummyFastPartitioning,
                  "_get_single_cell",
                  wraps=bd._get_single_cell,
              ) as mock_get_single_cell:
                  bd.update(Y=Y.unsqueeze(0)[:, :0])
                  mock_get_single_cell.assert_called_once()
  
          # test that update_local_upper_bounds_incremental is called when m>2
          bd = DummyFastPartitioning(ref_point=ref_point)
          with mock.patch(
              "botorch.utils.multi_objective.box_decompositions.box_decomposition."
              "update_local_upper_bounds_incremental",
              wraps=update_local_upper_bounds_incremental,
          ) as mock_update_local_upper_bounds_incremental, mock.patch.object(
              DummyFastPartitioning,
              "_get_partitioning",
              wraps=bd._get_partitioning,
          ) as mock_get_partitioning, mock.patch.object(
              DummyFastPartitioning,
              "_partition_space_2d",
          ):
              bd.update(Y=Y)
              if m > 2:
                  mock_update_local_upper_bounds_incremental.assert_called_once()
                  # check that it is not called if the pareto set does not change
                  bd.update(Y=Y)
                  mock_update_local_upper_bounds_incremental.assert_called_once()
                  mock_get_partitioning.assert_called_once()
              else:
                  self.assertEqual(
                      len(
                          mock_update_local_upper_bounds_incremental.call_args_list
                      ),
                      0,
                  )
  
          # test exception is raised for m=2, batched box decomposition using
          # _partition_space
          if m == 2:
              with self.assertRaises(NotImplementedError):
                  DummyFastPartitioning(
                      ref_point=ref_point, 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 3 for calling the TestBoxDecomposition obj's underlying member method code with example usage: obj.test_fast_partitioning() without return types