class_docstr: Tests confusion matrix metrics.
docstr: Test metric calculation where one of the metrics is NaN.
code: def test_with_nans(self):
      """Test metric calculation where one of the metrics is NaN."""
  
      confusion_matrices = [np.array([[[0, 1], [0, 2]]])]
      metrics = evaluation_lib.compute_confusion_matrix_metrics(
          confusion_matrices, return_per_class_metrics=True
      )
  
      self.assertAlmostEqual(metrics["recall/mean"], np.mean([0, 1]))
      self.assertAlmostEqual(metrics["recall/0"], 0)
      self.assertAlmostEqual(metrics["recall/1"], 1)
      self.assertAlmostEqual(
          metrics["precision/mean"], 2 / 3
      )  #  Should not not average over NaN metrics
      self.assertAlmostEqual(
          metrics["precision/0"], 0
      )  # Actually it's NaN
      self.assertAlmostEqual(metrics["precision/1"], 2 / 3)
      self.assertAlmostEqual(
          metrics["jaccard/mean"], np.mean([0, 2 / 3])
      )
      self.assertAlmostEqual(metrics["jaccard/0"], 0)
      self.assertAlmostEqual(metrics["jaccard/1"], 2 / 3)
  
file_path: scenic/scenic/projects/vivit/tests/test_vivit_metrics.py
imports: from absl.testing import absltest
  import jax.numpy
  import numpy
  from scenic.projects.vivit import evaluation_lib
  from scenic.projects.vivit import model_utils
label_desc: Use image node_id 2 for calling the ConfusionMatrixTester obj's underlying member method code with example usage: obj.test_with_nans() without return types