code: def snr_mixer(
      clean: torch.Tensor,
      noise: torch.Tensor,
      snr: int,
      min_overlap: float,
      target_level: int = -25,
      clipping_threshold: float = 0.99,
  ) -> torch.Tensor:
      """Function to mix clean speech and noise at various SNR levels.
  
      Args:
          clean (torch.Tensor): Clean audio source to mix, of shape [B, T].
          noise (torch.Tensor): Noise audio source to mix, of shape [B, T].
          snr (int): SNR level when mixing.
          min_overlap (float): Minimum overlap between the two mixed sources.
          target_level (int): Gain level in dB.
          clipping_threshold (float): Threshold for clipping the audio.
      Returns:
          torch.Tensor: The mixed audio, of shape [B, T].
      """
      if clean.shape[1] > noise.shape[1]:
          noise = torch.nn.functional.pad(
              noise, (0, clean.shape[1] - noise.shape[1])
          )
      else:
          noise = noise[:, : clean.shape[1]]
  
      # normalizing to -25 dB FS
      clean = clean / (clean.max(1)[0].abs().unsqueeze(1) + EPS)
      clean = normalize(clean, target_level)
      rmsclean = rms_f(clean)
  
      noise = noise / (noise.max(1)[0].abs().unsqueeze(1) + EPS)
      noise = normalize(noise, target_level)
      rmsnoise = rms_f(noise)
  
      # set the noise level for a given SNR
      noisescalar = (
          rmsclean / (10 ** (snr / 20)) / (rmsnoise + EPS)
      ).unsqueeze(1)
      noisenewlevel = noise * noisescalar
  
      # mix noise and clean speech
      noisyspeech = mix_pair(clean, noisenewlevel, min_overlap)
  
      # randomly select RMS value between -15 dBFS and -35 dBFS and normalize noisyspeech with that value
      # there is a chance of clipping that might happen with very less probability, which is not a major issue.
      noisy_rms_level = np.random.randint(
          TARGET_LEVEL_LOWER, TARGET_LEVEL_UPPER
      )
      rmsnoisy = rms_f(noisyspeech)
      scalarnoisy = (
          10 ** (noisy_rms_level / 20) / (rmsnoisy + EPS)
      ).unsqueeze(1)
      noisyspeech = noisyspeech * scalarnoisy
      clean = clean * scalarnoisy
      noisenewlevel = noisenewlevel * scalarnoisy
  
      # final check to see if there are any amplitudes exceeding +/- 1. If so, normalize all the signals accordingly
      clipped = is_clipped(noisyspeech)
      if clipped.any():
          noisyspeech_maxamplevel = noisyspeech[clipped].max(1)[
              0
          ].abs().unsqueeze(1) / (clipping_threshold - EPS)
          noisyspeech[clipped] = (
              noisyspeech[clipped] / noisyspeech_maxamplevel
          )
  
      return noisyspeech
  
imports: from dataclasses import dataclass, fields, replace
  import json
  from pathlib import Path
  import random
  import typing
  import numpy
  import torch
  from .info_audio_dataset import InfoAudioDataset, get_keyword_or_keyword_list
  from ..modules.conditioners import ConditioningAttributes, SegmentWithAttributes, WavCondition
label_desc: Use image node_id 5 for calling a global function with example usage: snr_mixer(clean, noise, snr, min_overlap, target_level, clipping_threshold) and returns: noisyspeech