class_docstr: Base AudioVideo Reader
  
  Args:
      opts: command line arguments
      is_training: Training or validation mode. Default: `False`.
class_docstr_tok: ["Base","AudioVideo","Reader","Args",":","opts",":","command","line","arguments","is_training",":","Training","or","validation","mode",".","Default",":","`","False","`","."]
docstr: Given entire video tensor of a video file and the indices of the sampled
  video frames, return the video clips. If there's not enough frames, the last
  frame will be padded. If `output_video_fps` is smaller than
  `original_video_fps`, video frames will be downsampled accordingly.
  
  Args:
      full_video_tensor: A [T x 3 x H x W] tensor of all frames of a video, where
          T is the total number of frames, H and W is the height and width of each
          frame image.
      vclip_ids: A [clips_per_video x N] tensor of the index of the sampled frames
          in `full_video_tensor`, where N is the number of sampled frames.
      metadata: A dictionary of the video's metadata information.
      num_frames_per_clip: Number of frames of the output clips.
      clips_per_video: Number of clips per video.
      original_video_fps: The frame rate of the video.
      output_video_fps: The frame rate of the output video clips.
      is_training: Whether it's in training mode. No randomness is applied if set
          False.
      num_samples_per_clip: Number of samples per clip to generate when the frames
          are downsampled.
  
  Returns:
      video_clips: A [clips_per_video x num_frames_per_clip x 3 x H x W] tensor.
docstr_tok: ["Given","entire","video","tensor","of","a","video","file","and","the","indices","of","the","sampled","video","frames",",","return","the","video","clips",".","If","there","'s","not","enough","frames",",","the","last","frame","will","be","padded",".","If","`","output_video_fps","`","is","smaller","than","`","original_video_fps","`",",","video","frames","will","be","downsampled","accordingly",".","Args",":","full_video_tensor",":","A","[","T","x","3","x","H","x","W","]","tensor","of","all","frames","of","a","video",",","where","T","is","the","total","number","of","frames",",","H","and","W","is","the","height","and","width","of","each","frame","image",".","vclip_ids",":","A","[","clips_per_video","x","N","]","tensor","of","the","index","of","the","sampled","frames","in","`","full_video_tensor","`",",","where","N","is","the","number","of","sampled","frames",".","metadata",":","A","dictionary","of","the","video","'s","metadata","information",".","num_frames_per_clip",":","Number","of","frames","of","the","output","clips",".","clips_per_video",":","Number","of","clips","per","video",".","original_video_fps",":","The","frame","rate","of","the","video",".","output_video_fps",":","The","frame","rate","of","the","output","video","clips",".","is_training",":","Whether","it","'s","in","training","mode",".","No","randomness","is","applied","if","set","False",".","num_samples_per_clip",":","Number","of","samples","per","clip","to","generate","when","the","frames","are","downsampled",".","Returns",":","video_clips",":","A","[","clips_per_video","x","num_frames_per_clip","x","3","x","H","x","W","]","tensor","."]
code: def _generate_video_clips(
      self,
      full_video_tensor: torch.Tensor,
      vclip_ids: Optional[torch.Tensor],
      metadata: Dict,
      num_frames_per_clip: int,
      clips_per_video: int,
      original_video_fps: float,
      output_video_fps: float,
      is_training: bool,
      num_samples_per_clip: Optional[int],
  ) -> Tuple[torch.Tensor, Dict]:
      """Given entire video tensor of a video file and the indices of the sampled
      video frames, return the video clips. If there's not enough frames, the last
      frame will be padded. If `output_video_fps` is smaller than
      `original_video_fps`, video frames will be downsampled accordingly.
  
      Args:
          full_video_tensor: A [T x 3 x H x W] tensor of all frames of a video, where
              T is the total number of frames, H and W is the height and width of each
              frame image.
          vclip_ids: A [clips_per_video x N] tensor of the index of the sampled frames
              in `full_video_tensor`, where N is the number of sampled frames.
          metadata: A dictionary of the video's metadata information.
          num_frames_per_clip: Number of frames of the output clips.
          clips_per_video: Number of clips per video.
          original_video_fps: The frame rate of the video.
          output_video_fps: The frame rate of the output video clips.
          is_training: Whether it's in training mode. No randomness is applied if set
              False.
          num_samples_per_clip: Number of samples per clip to generate when the frames
              are downsampled.
  
      Returns:
          video_clips: A [clips_per_video x num_frames_per_clip x 3 x H x W] tensor.
      """
      (
          num_video_frames,
          frame_channels,
          frame_height,
          frame_width,
      ) = full_video_tensor.shape
  
      if num_video_frames < num_frames_per_clip:
          # Repeat the last frame.
          num_video_frames_to_pad = (
              num_frames_per_clip - num_video_frames
          )
          padded_video = torch.zeros(
              size=(
                  num_frames_per_clip,
                  frame_channels,
                  frame_height,
                  frame_width,
              ),
              dtype=full_video_tensor.dtype,
              device=full_video_tensor.device,
          )
          padded_video[:num_video_frames] = full_video_tensor
          padded_video[num_video_frames:, :, :, :] = full_video_tensor[
              -1
          ].unsqueeze(0)
          num_repeats = (
              clips_per_video * num_samples_per_clip
              if is_training
              else clips_per_video
          )
          video_clips = padded_video.repeat((num_repeats, 1, 1, 1, 1))
          vclip_ids = torch.zeros((num_repeats, 1)) + torch.arange(
              num_video_frames
          )
          vclip_ids = F.pad(
              vclip_ids, (0, num_video_frames_to_pad), mode="replicate"
          )
  
      else:
          if 0 < output_video_fps < original_video_fps:
              vclip_ids = _downsample_frame_indices(
                  frame_indices=vclip_ids,
                  input_fps=original_video_fps,
                  output_num_frames=num_frames_per_clip,
                  output_fps=output_video_fps,
                  num_samples=num_samples_per_clip,
                  random_frames=is_training,
              )
          else:
              if num_samples_per_clip > 1:
                  # Duplicate video if multiple samples are generated for each clip at
                  # training time.
                  vclip_ids = torch.repeat_interleave(
                      vclip_ids, num_samples_per_clip, dim=0
                  )
  
          video_clips = full_video_tensor[vclip_ids]
  
      metadata["video_frame_timestamps"] = (
          vclip_ids / original_video_fps
      )
      if self.channel_first_format:
          video_clips = video_clips.transpose(1, 2)
      return video_clips, metadata
  
imports: import argparse
  import random
  from typing import Dict, Optional, Tuple
  import av
  import numpy
  import torch
  import torch.nn.functional
  from torch import Tensor
  from data.transforms import BaseTransformation
  from data.transforms import image_pil
  from data.transforms.common import Compose
  from options.utils import extend_selected_args_with_prefix, extract_opts_with_prefix_replacement
  from utils import logger
label_desc: Use image node_id 11 for calling the BaseAVReader obj's underlying member method code with example usage: obj._generate_video_clips(full_video_tensor, vclip_ids, metadata, num_frames_per_clip, clips_per_video, original_video_fps, output_video_fps, is_training, num_samples_per_clip) and returns: video_clips,  metadata