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.
  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.
      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 plotted 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",".","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",".","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","plotted","on","them","."]
code: def draw_clip(
      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,
      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.
      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.
          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 plotted on them.
      """
      assert (
          repeat_frame >= 1
      ), "`repeat_frame` must be a positive integer."
  
      repeated_seq = range(0, len(frames))
      repeated_seq = list(
          itertools.chain.from_iterable(
              itertools.repeat(x, repeat_frame) for x in repeated_seq
          )
      )
  
      frames, adjusted = self._adjust_frames_type(frames)
      if keyframe_idx is None:
          half_left = len(repeated_seq) // 2
          half_right = (len(repeated_seq) + 1) // 2
      else:
          mid = int((keyframe_idx / len(frames)) * len(repeated_seq))
          half_left = mid
          half_right = len(repeated_seq) - mid
  
      alpha_ls = np.concatenate(
          [
              np.linspace(0, 1, num=half_left),
              np.linspace(1, 0, num=half_right),
          ]
      )
      text_alpha = text_alpha
      frames = frames[repeated_seq]
      img_ls = []
      for alpha, frame in zip(alpha_ls, frames):
          draw_img = self.draw_one_frame(
              frame,
              preds,
              bboxes,
              alpha=alpha,
              text_alpha=text_alpha,
              ground_truth=ground_truth,
          )
          if adjusted:
              draw_img = draw_img.astype("float32") / 255
  
          img_ls.append(draw_img)
  
      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 5 for calling the VideoVisualizer obj's underlying member method code with example usage: obj.draw_clip(frames, preds, bboxes, text_alpha, ground_truth, keyframe_idx, repeat_frame) and returns: img_ls