class_docstr: Uniformly sample reference frames.
  
  Args:
      num_ref_imgs (int): Number of reference frames to be sampled.
      frame_range (int | list[int]): Range of frames to be sampled around
          key frame. If int, the range is [-frame_range, frame_range].
          Defaults to 10.
      filter_key_img (bool): Whether to filter the key frame when
          sampling reference frames. Defaults to True.
      collect_video_keys (list[str]): The keys of video info to be
          collected.
class_docstr_tok: ["Uniformly","sample","reference","frames",".","Args",":","num_ref_imgs","(","int",")",":","Number","of","reference","frames","to","be","sampled",".","frame_range","(","int","|","list","[","int","]",")",":","Range","of","frames","to","be","sampled","around","key","frame",".","If","int",",","the","range","is","[","-frame_range",",","frame_range","]",".","Defaults","to","10.","filter_key_img","(","bool",")",":","Whether","to","filter","the","key","frame","when","sampling","reference","frames",".","Defaults","to","True",".","collect_video_keys","(","list","[","str","]",")",":","The","keys","of","video","info","to","be","collected","."]
docstr: Sampling frames.
  
  Args:
      video_length (int): The length of the video.
      key_frame_id (int): The key frame id.
  
  Returns:
      list[int]: The sampled frame indices.
docstr_tok: ["Sampling","frames",".","Args",":","video_length","(","int",")",":","The","length","of","the","video",".","key_frame_id","(","int",")",":","The","key","frame","id",".","Returns",":","list","[","int","]",":","The","sampled","frame","indices","."]
code: def sampling_frames(self, video_length: int, key_frame_id: int):
      """Sampling frames.
  
      Args:
          video_length (int): The length of the video.
          key_frame_id (int): The key frame id.
  
      Returns:
          list[int]: The sampled frame indices.
      """
      if video_length > 1:
          left = max(0, key_frame_id + self.frame_range[0])
          right = min(
              key_frame_id + self.frame_range[1], video_length - 1
          )
          frame_ids = list(range(0, video_length))
  
          valid_ids = frame_ids[left : right + 1]
          if self.filter_key_img and key_frame_id in valid_ids:
              valid_ids.remove(key_frame_id)
          assert (
              len(valid_ids) > 0
          ), "After filtering key frame, there are no valid frames"
          if len(valid_ids) < self.num_ref_imgs:
              valid_ids = valid_ids * self.num_ref_imgs
          ref_frame_ids = random.sample(valid_ids, self.num_ref_imgs)
      else:
          ref_frame_ids = [key_frame_id] * self.num_ref_imgs
  
      sampled_frames_ids = [key_frame_id] + ref_frame_ids
      sampled_frames_ids = sorted(sampled_frames_ids)
  
      key_frames_ind = sampled_frames_ids.index(key_frame_id)
      key_frame_flags = [False] * len(sampled_frames_ids)
      key_frame_flags[key_frames_ind] = True
      return sampled_frames_ids, key_frame_flags
  
file_path: mmdetection/mmdet/datasets/transforms/frame_sampling.py
imports: import random
  from collections import defaultdict
  from typing import Dict, List, Optional, Union
  from mmcv.transforms import BaseTransform
  from mmdet.registry import TRANSFORMS
label_desc: Use image node_id 2 for calling the UniformRefFrameSample obj's underlying member method code with example usage: obj.sampling_frames(video_length, key_frame_id) and returns: sampled_frames_ids,  key_frame_flags