docstr: Draw predicted labels or ground truth classes to clip.
  Draw bouding boxes to clip if bboxes is provided. Boxes will gradually
  fade in and out the clip, centered around the clip's central frame,
  within the provided `draw_range`.
  Args:
      frames (array-like): video data in the shape (T, H, W, C).
      preds (tensor): a tensor of shape (num_boxes, num_classes) that
          contains all of the confidence scores of the model. For recognition
          task or for ground_truth labels, input shape can be (num_classes,).
      bboxes (Optional[tensor]): shape (num_boxes, 4) that contains the coordinates
          of the bounding boxes.
      text_alpha (float): transparency label of the box wrapped around text labels.
      ground_truth (bool): whether the prodived bounding boxes are ground-truth.
      keyframe_idx (int): the index of keyframe in the clip.
      draw_range (Optional[list[ints]): only draw frames in range
          [start_idx, end_idx] inclusively in the clip. If None, draw on
          the entire clip.
      repeat_frame (int): repeat each frame in draw_range for `repeat_frame`
          time for slow-motion effect.
  Returns:
      A list of frames with bounding box annotations and corresponding
      bbox labels ploted on them.
docstr_tok: ["Draw","predicted","labels","or","ground","truth","classes","to","clip",".","Draw","bouding","boxes","to","clip","if","bboxes","is","provided",".","Boxes","will","gradually","fade","in","and","out","the","clip",",","centered","around","the","clip","'s","central","frame",",","within","the","provided","`","draw_range","`",".","Args",":","frames","(","array-like",")",":","video","data","in","the","shape","(","T",",","H",",","W",",","C",")",".","preds","(","tensor",")",":","a","tensor","of","shape","(","num_boxes",",","num_classes",")","that","contains","all","of","the","confidence","scores","of","the","model",".","For","recognition","task","or","for","ground_truth","labels",",","input","shape","can","be","(","num_classes",",",")",".","bboxes","(","Optional","[","tensor","]",")",":","shape","(","num_boxes",",","4",")","that","contains","the","coordinates","of","the","bounding","boxes",".","text_alpha","(","float",")",":","transparency","label","of","the","box","wrapped","around","text","labels",".","ground_truth","(","bool",")",":","whether","the","prodived","bounding","boxes","are","ground-truth",".","keyframe_idx","(","int",")",":","the","index","of","keyframe","in","the","clip",".","draw_range","(","Optional","[","list","[","ints","]",")",":","only","draw","frames","in","range","[","start_idx",",","end_idx","]","inclusively","in","the","clip",".","If","None",",","draw","on","the","entire","clip",".","repeat_frame","(","int",")",":","repeat","each","frame","in","draw_range","for","`","repeat_frame","`","time","for","slow-motion","effect",".","Returns",":","A","list","of","frames","with","bounding","box","annotations","and","corresponding","bbox","labels","ploted","on","them","."]
code: def draw_clip_range(
      self,
      frames: Union[torch.Tensor, np.ndarray],
      preds: Union[torch.Tensor, List[float]],
      bboxes: Optional[torch.Tensor] = None,
      text_alpha: float = 0.5,
      ground_truth: bool = False,
      keyframe_idx: Optional[int] = None,
      draw_range: Optional[List[int]] = None,
      repeat_frame: int = 1,
  ) -> List[np.ndarray]:
      """
      Draw predicted labels or ground truth classes to clip.
      Draw bouding boxes to clip if bboxes is provided. Boxes will gradually
      fade in and out the clip, centered around the clip's central frame,
      within the provided `draw_range`.
      Args:
          frames (array-like): video data in the shape (T, H, W, C).
          preds (tensor): a tensor of shape (num_boxes, num_classes) that
              contains all of the confidence scores of the model. For recognition
              task or for ground_truth labels, input shape can be (num_classes,).
          bboxes (Optional[tensor]): shape (num_boxes, 4) that contains the coordinates
              of the bounding boxes.
          text_alpha (float): transparency label of the box wrapped around text labels.
          ground_truth (bool): whether the prodived bounding boxes are ground-truth.
          keyframe_idx (int): the index of keyframe in the clip.
          draw_range (Optional[list[ints]): only draw frames in range
              [start_idx, end_idx] inclusively in the clip. If None, draw on
              the entire clip.
          repeat_frame (int): repeat each frame in draw_range for `repeat_frame`
              time for slow-motion effect.
      Returns:
          A list of frames with bounding box annotations and corresponding
          bbox labels ploted on them.
      """
      if draw_range is None:
          draw_range = [0, len(frames) - 1]
      if draw_range is not None:
          draw_range[0] = max(0, draw_range[0])
          left_frames = frames[: draw_range[0]]
          right_frames = frames[draw_range[1] + 1 :]
  
      draw_frames = frames[draw_range[0] : draw_range[1] + 1]
      if keyframe_idx is None:
          keyframe_idx = len(frames) // 2
  
      img_ls = (
          list(left_frames)
          + self.draw_clip(
              draw_frames,
              preds,
              bboxes=bboxes,
              text_alpha=text_alpha,
              ground_truth=ground_truth,
              keyframe_idx=keyframe_idx - draw_range[0],
              repeat_frame=repeat_frame,
          )
          + list(right_frames)
      )
  
      return img_ls
  
imports: from __future__ import annotations
  import itertools
  import logging
  from types import SimpleNamespace
  from typing import Dict, List, Optional, Tuple, Union
  import matplotlib.pyplot
  import numpy
  import torch
  from detectron2.utils.visualizer import Visualizer
label_desc: Use image node_id 4 for calling the VideoVisualizer obj's underlying member method code with example usage: obj.draw_clip_range(frames, preds, bboxes, text_alpha, ground_truth, keyframe_idx, draw_range, repeat_frame) and returns: img_ls