code: def test_compute_perplexity(self):
      probs = np.arange(100).reshape(2, 5, 10) / 100
  
      ppl = FlaxWav2Vec2GumbelVectorQuantizer._compute_perplexity(probs)
      self.assertTrue(abs(ppl.item() - 141.4291) < 1e-3)
  
      # mask half of the input
      mask = np.ones((2,), dtype=bool)
      mask[0] = 0
  
      ppl = FlaxWav2Vec2GumbelVectorQuantizer._compute_perplexity(
          probs, mask
      )
      self.assertTrue(abs(ppl.item() - 58.6757) < 1e-3)
  
imports: import inspect
  import math
  import multiprocessing
  import traceback
  import unittest
  import numpy
  from datasets import load_dataset
  from transformers import Wav2Vec2Config, is_flax_available
  from transformers.testing_utils import CaptureLogger, is_flaky, is_librosa_available, is_pt_flax_cross_test, is_pyctcdecode_available, require_flax, require_librosa, require_pyctcdecode, require_soundfile, run_test_in_subprocess, slow
  from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, random_attention_mask
label_desc: Use image node_id 4 for calling the FlaxWav2Vec2UtilsTest obj's underlying member method code with example usage: obj.test_compute_perplexity() without return types