docstr: Simple test to confirm that the FSQ module can be instantiated and run,
  and that forward produces the same result as encode-decode.
docstr_tok: ["Simple","test","to","confirm","that","the","FSQ","module","can","be","instantiated","and","run",",","and","that","forward","produces","the","same","result","as","encode-decode","."]
code: def test_fsq_eval(self, num_levels: list):
      """Simple test to confirm that the FSQ module can be instantiated and run,
      and that forward produces the same result as encode-decode.
      """
      fsq = FiniteScalarQuantizer(num_levels=num_levels)
  
      for i in range(self.num_examples):
          inputs = torch.randn(
              [self.batch_size, fsq.codebook_dim, self.max_len]
          )
          input_len = torch.tensor(
              [self.max_len] * self.batch_size, dtype=torch.int32
          )
  
          # apply forward
          dequantized_fw, indices_fw = fsq(
              inputs=inputs, input_len=input_len
          )
  
          assert (
              dequantized_fw.max() <= 1.0
          ), f"example {i}: dequantized_fw.max() is {dequantized_fw.max()}"
          assert (
              dequantized_fw.min() >= -1.0
          ), f"example {i}: dequantized_fw.min() is {dequantized_fw.min()}"
  
          # encode-decode
          indices_enc = fsq.encode(inputs=inputs, input_len=input_len)
          dequantized_dec = fsq.decode(
              indices=indices_enc, input_len=input_len
          )
  
          # make sure the results are the same
          torch.testing.assert_close(
              indices_enc,
              indices_fw,
              msg=f"example {i}: indices mismatch",
          )
          torch.testing.assert_close(
              dequantized_dec,
              dequantized_fw,
              msg=f"example {i}: dequantized mismatch",
          )
  
imports: import pytest
  import torch
  from nemo.collections.tts.modules.audio_codec_modules import CodecActivation, Conv1dNorm, ConvTranspose1dNorm, FiniteScalarQuantizer, GroupFiniteScalarQuantizer, get_down_sample_padding
  from nemo.collections.tts.modules.encodec_modules import GroupResidualVectorQuantizer, ResidualVectorQuantizer
label_desc: Use image node_id 2 for calling the TestFiniteScalarQuantizer obj's underlying member method code with example usage: obj.test_fsq_eval(num_levels) without return types