docstr: soundfile_backend.save passes correct subtype and format to soundfile.write when SPHERE
docstr_tok: ["soundfile_backend.save","passes","correct","subtype","and","format","to","soundfile.write","when","SPHERE"]
code: def assert_non_wav(
      self,
      fmt,
      dtype,
      sample_rate,
      num_channels,
      channels_first,
      mocked_write,
      encoding=None,
      bits_per_sample=None,
  ):
      """soundfile_backend.save passes correct subtype and format to soundfile.write when SPHERE"""
      filepath = f"foo.{fmt}"
      input_tensor = get_wav_data(
          dtype,
          num_channels,
          num_frames=3 * sample_rate,
          normalize=False,
          channels_first=channels_first,
      ).t()
      expected_data = (
          input_tensor.t() if channels_first else input_tensor
      )
  
      soundfile_backend.save(
          filepath,
          input_tensor,
          sample_rate,
          channels_first,
          encoding=encoding,
          bits_per_sample=bits_per_sample,
      )
  
      # on +Py3.8 call_args.kwargs is more descreptive
      args = mocked_write.call_args[1]
      assert args["file"] == filepath
      assert args["samplerate"] == sample_rate
      if fmt in ["sph", "nist", "nis"]:
          assert args["format"] == "NIST"
      else:
          assert args["format"] is None
      self.assertEqual(args["data"], expected_data)
  
imports: import io
  from unittest.mock import patch
  from torchaudio._internal import module_utils
  from torchaudio.backend import soundfile_backend
  from torchaudio_unittest.common_utils import get_wav_data, load_wav, nested_params, PytorchTestCase, skipIfNoModule, TempDirMixin
  from .common import fetch_wav_subtype, parameterize, skipIfFormatNotSupported
label_desc: Use image node_id 2 for calling the MockedSaveTest obj's underlying member method code with example usage: obj.assert_non_wav(fmt, dtype, sample_rate, num_channels, channels_first, mocked_write, encoding, bits_per_sample) without return types