code: def test_uniform_ref_frame_sample(self):
      sampler = UniformRefFrameSample(
          num_ref_imgs=2, frame_range=[-1, 1], filter_key_img=True
      )
      results = sampler(self.video_infos)
      assert isinstance(results, dict)
      for key in self.info_keys:
          assert key in results
          assert len(results[key]) == 3
          if key == "frame_id":
              assert results[key] == [3, 4, 5]
  
      key_frame_id = self.video_infos["key_frame_id"]
      assert (
          results["img"][1]
          == np.zeros((self.H, self.W, 3)) + key_frame_id
      ).all()
      assert (
          results["gt_bboxes"][1] == np.zeros((2, 4)) + key_frame_id
      ).all()
      assert (
          results["gt_bboxes_labels"][1]
          == np.zeros((2,)) + key_frame_id
      ).all()
      assert (
          results["gt_instances_id"][1] == np.zeros((2,)) + key_frame_id
      ).all()
      assert results["ori_shape"][1] == (
          self.H + key_frame_id,
          self.W + key_frame_id,
      )
      assert results["img_id"][1] == key_frame_id
  
      # test the filter_key_img and the correctness of returned frame index
      sampler = UniformRefFrameSample(
          num_ref_imgs=2, frame_range=[0, 1], filter_key_img=False
      )
      results = sampler(self.video_infos)
      assert 4 in results["img_id"] and results["img_id"].count(4) == 2
      assert 5 in results["img_id"] and results["img_id"].count(5) == 1
      assert results["key_frame_flags"] == [True, False, False]
  
file_path: mmdetection/tests/test_datasets/test_transforms/test_frame_sampling.py
imports: import unittest
  import numpy
  from mmdet.datasets.transforms import BaseFrameSample, UniformRefFrameSample
label_desc: Use image node_id 3 for calling the TestFrameSample obj's underlying member method code with example usage: obj.test_uniform_ref_frame_sample() without return types