code: def _stream_to_wav(
      x: torch.Tensor, dtype: str, audio_fps: int
  ) -> bytes:
      """
      Take in a tensor of audio values in [-1, 1] and save it as a wav file with
      values of the given @dtype.
  
      Args:
          x: a tensor of shape [N] or [C, N], where, C is the number of channels,
              and N is the number of samples.
          dtype: The data type to which @x should be converted before being saved.
          audio_fps: The audio framerate at which x should be stored.
  
      Returns:
          The bytes of the wav file.
      """
      assert x.dtype == torch.float32
  
      if dtype == "float32":
          pass
      elif dtype == "int32":
          x = x * (2**31 - 1)
          x = x.to(dtype=torch.int32)
      elif dtype == "int16":
          x = x * (2**15 - 1)
          x = x.to(dtype=torch.int16)
      elif dtype == "uint8":
          x = (x + 1) * (2**8 - 1) / 2
          x = x.to(dtype=torch.uint8)
  
      if x.dim() == 1:
          x = x.reshape(1, -1)
      buffer = io.BytesIO()
      torchaudio.save(buffer, x, audio_fps, format="wav")
      buffer.seek(0)
      byte_values = buffer.read()
  
      return byte_values
  
file_path: ml-cvnets/data/transforms/audio_bytes.py
imports: import argparse
  import io
  import tempfile
  from typing import Dict, Union
  import numpy
  import torch
  import torchaudio
  from data.transforms import TRANSFORMATIONS_REGISTRY, BaseTransformation
label_desc: Use image node_id 1 for calling a global function with example usage: _stream_to_wav(x, dtype, audio_fps) and returns: byte_values