code: def test_weighted_f_score(self):
      # predictions = [1, 1, 2, 1, 1].
      model_outputs = np.array(
          [
              [0, 1, 0, 0],
              [0, 1, 0, 0],
              [0, 0, 1, 0],
              [0, 1, 0, 0],
              [0, 1, 0, 0],
          ]
      )
      targets = np.array([1, 2, 2, 3, 1])
      # Category indices starting with `0`.
      layer = tl.WeightedFScore()
      loss = layer([model_outputs, targets])
      self.assertAlmostEqual(loss, 0.533, places=3)
      # Excluding the padding index `0`.
      layer = tl.WeightedFScore(initial_category_index=1)
      loss = layer([model_outputs, targets])
      self.assertAlmostEqual(loss, 0.533, places=3)
  
imports: from absl.testing import absltest
  import numpy
  import trax.layers
label_desc: Use image node_id 20 for calling the MetricsTest obj's underlying member method code with example usage: obj.test_weighted_f_score() without return types