code: def _align_audio_frames(
      aframes: torch.Tensor,
      audio_frames: List["av.frame.Frame"],
      ref_start: int,
      ref_end: float,
  ) -> torch.Tensor:
      start, end = audio_frames[0].pts, audio_frames[-1].pts
      total_aframes = aframes.shape[1]
      step_per_aframe = (end - start + 1) / total_aframes
      s_idx = 0
      e_idx = total_aframes
      if start < ref_start:
          s_idx = int((ref_start - start) / step_per_aframe)
      if end > ref_end:
          e_idx = int((ref_end - end) / step_per_aframe)
      return aframes[:, s_idx:e_idx]
  
file_path: vision/torchvision/io/video.py
imports: import gc
  import math
  import os
  import re
  import warnings
  from fractions import Fraction
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from ..utils import _log_api_usage_once
  from .None import _video_opt
label_desc: Use image node_id 5 for calling a global function with example usage: _align_audio_frames(aframes, audio_frames, ref_start, ref_end) and returns: aframes