code: def _crop_audio_label(
      waveform: torch.Tensor,
      label: torch.Tensor,
      length: torch.Tensor,
      num_frames: int,
      rand_crop: bool,
      window_size: int = 25,
      window_shift: int = 20,
      sample_rate: int = 16,
  ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
      """Collate the audio and label at the same time.
  
      Args:
          waveform (Tensor): The waveform Tensor with dimensions `(time)`.
          label (Tensor): The label Tensor with dimensions `(seq)`.
          length (Tensor): The length Tensor with dimension `(1,)`.
          num_frames (int): The final length of the waveform.
          rand_crop (bool): if ``rand_crop`` is True, the starting index of the
              waveform and label is random if the length is longer than the minimum
              length in the mini-batch.
          window_size (int): reception field of conv feature extractor (in ms).
              In default, calculated by [400 (samples) / 16 (sample_rate)].
          window_shift (int): the stride of conv feature extractor (in ms).
              In default, calculated by [320 (samples) / 16 (sample_rate)].
          sample_rate (int): number of samples in audio signal per millisecond.
  
      Returns:
          (Tuple(Tensor, Tensor, Tensor)): Returns the Tensors for the waveform,
              label, and the waveform length.
  
      """
  
      frame_offset = 0
      if waveform.size > num_frames and rand_crop:
          diff = waveform.size - num_frames
          frame_offset = torch.randint(diff, size=(1,))
      elif waveform.size < num_frames:
          num_frames = waveform.size
      label_offset = max(
          math.floor(
              (frame_offset - window_size * sample_rate)
              / (window_shift * sample_rate)
          )
          + 1,
          0,
      )
      num_label = (
          math.floor(
              (num_frames - window_size * sample_rate)
              / (window_shift * sample_rate)
          )
          + 1
      )
      waveform = waveform[frame_offset : frame_offset + num_frames]
      label = label[label_offset : label_offset + num_label]
      length = num_frames
  
      return waveform, label, length
  
file_path: espnet/espnet2/train/collate_fn.py
imports: import math
  from typing import Collection, Dict, List, Tuple, Union
  import numpy
  import torch
  from typeguard import check_argument_types, check_return_type
  from espnet.nets.pytorch_backend.nets_utils import pad_list
label_desc: Use image node_id 1 for calling a global function with example usage: _crop_audio_label(waveform, label, length, num_frames, rand_crop, window_size, window_shift, sample_rate) and returns: waveform,  label,  length