docstr: Simple test to confirm that the RVQ module can be instantiated and run,
  and that forward produces the same result as encode-decode.
docstr_tok: ["Simple","test","to","confirm","that","the","RVQ","module","can","be","instantiated","and","run",",","and","that","forward","produces","the","same","result","as","encode-decode","."]
code: def test_rvq_eval(self, num_codebooks: int):
      """Simple test to confirm that the RVQ module can be instantiated and run,
      and that forward produces the same result as encode-decode.
      """
      # instantiate and set in eval mode
      rvq = ResidualVectorQuantizer(
          num_codebooks=num_codebooks, codebook_dim=self.codebook_dim
      )
      rvq.eval()
  
      for i in range(self.num_examples):
          inputs = torch.randn(
              [self.batch_size, self.codebook_dim, self.max_len]
          )
          input_len = torch.tensor(
              [self.max_len] * self.batch_size, dtype=torch.int32
          )
  
          # apply forward
          dequantized_fw, indices_fw, commit_loss = rvq(
              inputs=inputs, input_len=input_len
          )
  
          # make sure the commit loss is zero
          assert (
              commit_loss == 0.0
          ), f"example {i}: commit_loss is {commit_loss}, expected 0.0"
  
          # encode-decode
          indices_enc = rvq.encode(inputs=inputs, input_len=input_len)
          dequantized_dec = rvq.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 TestResidualVectorQuantizer obj's underlying member method code with example usage: obj.test_rvq_eval(num_codebooks) without return types