code: def _parse_save_args(
      ext: Optional[str],
      format: Optional[str],
      encoding: Optional[str],
      bps: Optional[int],
  ):
      # torchaudio's save function accepts the followings, which do not 1to1 map
      # to FFmpeg.
      #
      # - format: audio format
      # - bits_per_sample: encoder sample format
      # - encoding: such as PCM_U8.
      #
      # In FFmpeg, format is specified with the following three (and more)
      #
      # - muxer: could be audio format or container format.
      # the one we passed to the constructor of StreamWriter
      # - encoder: the audio encoder used to encode audio
      # - encoder sample format: the format used by encoder to encode audio.
      #
      # If encoder sample format is different from source sample format, StreamWriter
      # will insert a filter automatically.
      #
      def _type(spec):
          # either format is exactly the specified one
          # or extension matches to the spec AND there is no format override.
          return format == spec or (format is None and ext == spec)
  
      if _type("wav") or _type("amb"):
          # wav is special because it supports different encoding through encoders
          # each encoder only supports one encoder format
          #
          # amb format is a special case originated from libsox.
          # It is basically a WAV format, with slight modification.
          # https://github.com/chirlu/sox/commit/4a4ea33edbca5972a1ed8933cc3512c7302fa67a#diff-39171191a858add9df87f5f210a34a776ac2c026842ae6db6ce97f5e68836795
          # It is a format so that decoders will recognize it as ambisonic.
          # https://www.ambisonia.com/Members/mleese/file-format-for-b-format/
          # FFmpeg does not recognize amb because it is basically a WAV format.
          muxer = "wav"
          encoder = _get_encoder_for_wav(encoding, bps)
          sample_fmt = None
      elif _type("vorbis"):
          # FFpmeg does not recognize vorbis extension, while libsox used to do.
          # For the sake of bakward compatibility, (and the simplicity),
          # we support the case where users want to do save("foo.vorbis")
          muxer = "ogg"
          encoder = "vorbis"
          sample_fmt = None
      else:
          muxer = format
          encoder = None
          sample_fmt = None
          if _type("flac"):
              sample_fmt = _get_flac_sample_fmt(bps)
          if _type("ogg"):
              sample_fmt = _get_flac_sample_fmt(bps)
      return muxer, encoder, sample_fmt
  
imports: import os
  import re
  import sys
  from typing import BinaryIO, Optional, Tuple, Union
  import torch
  import torchaudio
  from .backend import Backend
  from .common import AudioMetaData
label_desc: Use image node_id 9 for calling a global function with example usage: _parse_save_args(ext, format, encoding, bps) and returns: muxer,  encoder,  sample_fmt, unknown