docstr: Simple test to make sure the output of FSQ is correct for a single setup.
  
  To re-generate test vectors:
  ```
  num_examples, max_len = 5, 8
  inputs = torch.randn([num_examples, fsq.codebook_dim, max_len])
  input_len = torch.tensor([max_len] * num_examples, dtype=torch.int32)
  dequantized, indices = fsq(inputs=inputs, input_len=input_len)
  ```
docstr_tok: ["Simple","test","to","make","sure","the","output","of","FSQ","is","correct","for","a","single","setup",".","To","re-generate","test","vectors",":","``","`","num_examples",",","max_len","=","5",",","8","inputs","=","torch.randn","(","[","num_examples",",","fsq.codebook_dim",",","max_len","]",")","input_len","=","torch.tensor","(","[","max_len","]","*","num_examples",",","dtype=torch.int32",")","dequantized",",","indices","=","fsq","(","inputs=inputs",",","input_len=input_len",")","``","`"]
code: def test_fsq_output(self):
      """Simple test to make sure the output of FSQ is correct for a single setup.
  
      To re-generate test vectors:
      ```
      num_examples, max_len = 5, 8
      inputs = torch.randn([num_examples, fsq.codebook_dim, max_len])
      input_len = torch.tensor([max_len] * num_examples, dtype=torch.int32)
      dequantized, indices = fsq(inputs=inputs, input_len=input_len)
      ```
      """
      num_levels = [3, 4]
      fsq = FiniteScalarQuantizer(num_levels=num_levels)
  
      # inputs
      inputs = torch.tensor(
          [
              [
                  [
                      0.1483,
                      -0.3855,
                      -0.3715,
                      -0.5913,
                      -0.2212,
                      -0.4226,
                      -0.4864,
                      -1.6069,
                  ],
                  [
                      -0.5519,
                      -0.5307,
                      -0.5995,
                      -1.9675,
                      -0.4439,
                      0.3938,
                      -0.5636,
                      -0.3655,
                  ],
              ],
              [
                  [
                      0.5184,
                      1.4028,
                      0.1553,
                      -0.2324,
                      1.0363,
                      -0.4981,
                      -0.1203,
                      -1.0335,
                  ],
                  [
                      -0.1567,
                      -0.2274,
                      0.0424,
                      -0.0819,
                      -0.2122,
                      -2.1851,
                      -1.5035,
                      -1.2237,
                  ],
              ],
              [
                  [
                      0.9497,
                      0.8510,
                      -1.2021,
                      0.3299,
                      -0.2388,
                      0.8445,
                      2.2129,
                      -2.3383,
                  ],
                  [
                      1.5331,
                      0.0399,
                      -0.7676,
                      -0.4715,
                      -0.5713,
                      0.8761,
                      -0.9755,
                      -0.7479,
                  ],
              ],
              [
                  [
                      1.7243,
                      -1.2146,
                      -0.1969,
                      1.9261,
                      0.1109,
                      0.4028,
                      0.1240,
                      -0.0994,
                  ],
                  [
                      -0.3304,
                      2.1239,
                      0.1004,
                      -1.4060,
                      1.1463,
                      -0.0557,
                      -0.5856,
                      -1.2441,
                  ],
              ],
              [
                  [
                      2.3743,
                      -0.1421,
                      -0.4548,
                      0.6320,
                      -0.2640,
                      -0.3967,
                      -2.5694,
                      0.0493,
                  ],
                  [
                      0.3409,
                      0.2366,
                      -0.0309,
                      -0.7652,
                      0.3484,
                      -0.8419,
                      0.9079,
                      -0.9929,
                  ],
              ],
          ]
      )
  
      input_len = torch.tensor([8, 8, 8, 8, 8], dtype=torch.int32)
  
      # expected output
      dequantized_expected = torch.tensor(
          [
              [
                  [
                      0.0000,
                      0.0000,
                      0.0000,
                      -1.0000,
                      0.0000,
                      0.0000,
                      0.0000,
                      -1.0000,
                  ],
                  [
                      -0.5000,
                      -0.5000,
                      -0.5000,
                      -1.0000,
                      -0.5000,
                      0.0000,
                      -0.5000,
                      -0.5000,
                  ],
              ],
              [
                  [
                      0.0000,
                      1.0000,
                      0.0000,
                      0.0000,
                      1.0000,
                      0.0000,
                      0.0000,
                      -1.0000,
                  ],
                  [
                      0.0000,
                      0.0000,
                      0.0000,
                      0.0000,
                      0.0000,
                      -1.0000,
                      -1.0000,
                      -1.0000,
                  ],
              ],
              [
                  [
                      1.0000,
                      1.0000,
                      -1.0000,
                      0.0000,
                      0.0000,
                      1.0000,
                      1.0000,
                      -1.0000,
                  ],
                  [
                      0.5000,
                      0.0000,
                      -0.5000,
                      -0.5000,
                      -0.5000,
                      0.5000,
                      -0.5000,
                      -0.5000,
                  ],
              ],
              [
                  [
                      1.0000,
                      -1.0000,
                      0.0000,
                      1.0000,
                      0.0000,
                      0.0000,
                      0.0000,
                      0.0000,
                  ],
                  [
                      0.0000,
                      0.5000,
                      0.0000,
                      -1.0000,
                      0.5000,
                      0.0000,
                      -0.5000,
                      -1.0000,
                  ],
              ],
              [
                  [
                      1.0000,
                      0.0000,
                      0.0000,
                      1.0000,
                      0.0000,
                      0.0000,
                      -1.0000,
                      0.0000,
                  ],
                  [
                      0.0000,
                      0.0000,
                      0.0000,
                      -0.5000,
                      0.0000,
                      -0.5000,
                      0.5000,
                      -0.5000,
                  ],
              ],
          ]
      )
  
      indices_expected = torch.tensor(
          [
              [
                  [4, 4, 4, 0, 4, 7, 4, 3],
                  [7, 8, 7, 7, 8, 1, 1, 0],
                  [11, 8, 3, 4, 4, 11, 5, 3],
                  [8, 9, 7, 2, 10, 7, 4, 1],
                  [8, 7, 7, 5, 7, 4, 9, 4],
              ]
          ],
          dtype=torch.int32,
      )
  
      # test
      dequantized, indices = fsq(inputs=inputs, input_len=input_len)
      torch.testing.assert_close(
          dequantized, dequantized_expected, msg=f"dequantized mismatch"
      )
      torch.testing.assert_close(
          indices, indices_expected, msg=f"indices 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 3 for calling the TestFiniteScalarQuantizer obj's underlying member method code with example usage: obj.test_fsq_output() without return types