code: def test_shape(
      self,
      target_label0,
      target_label1,
      concat_fg_probs,
      expected_result_pos,
      expected_result_neg,
  ):
      compute_dtypes = [torch.float16, torch.float32]
      for compute_dtype in compute_dtypes:
          sampler = HardNegativeSampler(
              select_sample_size_per_image,
              positive_fraction,
              min_neg,
              pool_size,
          )
          target_labels = [
              torch.tensor(target_label0),
              torch.tensor(target_label1),
          ]
          result_pos, result_neg = sampler(
              target_labels,
              torch.tensor(concat_fg_probs, dtype=compute_dtype),
          )
          for r, er in zip(result_pos, expected_result_pos):
              assert_allclose(r, er)
          for r, er in zip(result_neg, expected_result_neg):
              assert_allclose(r, er)
  
file_path: MONAI/tests/test_hardnegsampler.py
imports: from __future__ import annotations
  import unittest
  import torch
  from parameterized import parameterized
  from monai.apps.detection.utils.hard_negative_sampler import HardNegativeSampler
  from tests.utils import assert_allclose
label_desc: Use image node_id 1 for calling the TestSampleSlices obj's underlying member method code with example usage: obj.test_shape(target_label0, target_label1, concat_fg_probs, expected_result_pos, expected_result_neg) without return types