code: def test_shuffle_audios(
      N: int,
      mode: str,
      shuffle_ratio: float,
      generate_frame_level_targets: bool,
      debug_mode: bool,
  ) -> None:
      opts = get_config()
      setattr(
          opts,
          f"video_augmentation.shuffle_audios.shuffle_ratio_{mode}",
          shuffle_ratio,
      )
      setattr(
          opts,
          "video_augmentation.shuffle_audios.generate_frame_level_targets",
          generate_frame_level_targets,
      )
      setattr(
          opts,
          "video_augmentation.shuffle_audios.debug_mode",
          debug_mode,
      )
  
      C_v, C_a = 3, 2
      H, W = 8, 8
      num_video_frames = 3
      num_audio_frames = 5
  
      video = torch.rand(N, num_video_frames, C_v, H, W)
      # Generating unique audio elements (using torch.arange) so that we can compare them to check if they are shuffled.
      input_audio = torch.empty(
          N, num_audio_frames, C_a, dtype=torch.float
      )
      torch.arange(
          input_audio.numel(), dtype=torch.float, out=input_audio
      )
  
      data = {
          "samples": {
              "video": video,
              "audio": input_audio.clone(),
              "metadata": {},
          },
          "targets": {},
      }
  
      result = ShuffleAudios(
          opts=opts,
          is_training=mode == "train",
          is_evaluation=mode == "test",
          item_index=0,
      )(data)
  
      labels = data["targets"]["is_shuffled"]
      assert (
          labels.shape == (N, num_video_frames)
          if generate_frame_level_targets
          else (N,)
      )
      if generate_frame_level_targets:
          assert torch.all(
              labels == labels[:, :1].repeat(1, num_video_frames)
          ), "Labels should be identical among frames of the same clip."
  
      result_is_shuffled = (
          (~torch.isclose(input_audio, result["samples"]["audio"]))
          .float()  # shape: N x num_audio_frames x C_a
          .mean(axis=1)  # shape: N x C_a
          .mean(axis=1)  # shape: N
      )
      actual_participation_ratio = result_is_shuffled.float().mean()
      if N > 1:
          assert actual_participation_ratio == pytest.approx(
              shuffle_ratio, abs=0.05
          )
      else:
          assert actual_participation_ratio == pytest.approx(
              0.0, abs=0.05
          )
  
      assert torch.allclose(
          result_is_shuffled,
          (
              labels[:, 0] if generate_frame_level_targets else labels
          ).float(),
      ), "Generated labels should match shuffled audios."
  
      if debug_mode:
          assert data["samples"]["metadata"][
              "shuffled_audio_permutation"
          ].shape == (N,)
      else:
          assert (
              "shuffled_audio_permutation"
              not in data["samples"]["metadata"]
          )
  
file_path: ml-cvnets/tests/transforms/test_video.py
imports: import operator
  import os
  from pathlib import Path
  from typing import Dict, Tuple
  import pytest
  import torch
  from data.transforms.video import CropByBoundingBox, SaveInputs, ShuffleAudios, _resize_fn
  from data.video_reader.pyav_reader import PyAVReader
  from tests.configs import get_config
label_desc: Use image node_id 4 for calling a global function with example usage: test_shuffle_audios(N, mode, shuffle_ratio, generate_frame_level_targets, debug_mode) without return types