code: def _align_audio_frames(
      aframes: torch.Tensor,
      aframe_pts: torch.Tensor,
      audio_pts_range: Tuple[int, int],
  ) -> torch.Tensor:
      start, end = aframe_pts[0], aframe_pts[-1]
      num_samples = aframes.size(0)
      step_per_aframe = float(end - start + 1) / float(num_samples)
      s_idx = 0
      e_idx = num_samples
      if start < audio_pts_range[0]:
          s_idx = int((audio_pts_range[0] - start) / step_per_aframe)
      if audio_pts_range[1] != -1 and end > audio_pts_range[1]:
          e_idx = int((audio_pts_range[1] - end) / step_per_aframe)
      return aframes[s_idx:e_idx, :]
  
imports: import math
  import warnings
  from fractions import Fraction
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  from ..extension import _load_library
label_desc: Use image node_id 3 for calling a global function with example usage: _align_audio_frames(aframes, aframe_pts, audio_pts_range) and returns: aframes