class_docstr: Tests for the SegmentationModel.
class_docstr_tok: ["Tests","for","the","SegmentationModel","."]
docstr: Tests globa_metric_function by checking its output's format and validity.
docstr_tok: ["Tests","globa_metric_function","by","checking","its","output","'s","format","and","validity","."]
code: def test_global_metric_function(self):
      """Tests globa_metric_function by checking its output's format and validity."""
      model = FakeSemanticSegmentationModel()
      _, _, all_confusion_mat = get_fake_batch_output()
      all_global_metrics = model.get_global_metrics_fn()(
          all_confusion_mat, {}
      )
  
      # Check expected metrics exist in the output:
      expected_global_metrics_keys = ["mean_iou"] + [
          f"iou_per_class/{label:02.0f}" for label in range(NUM_CLASSES)
      ]
      self.assertSameElements(
          expected_global_metrics_keys, all_global_metrics.keys()
      )
  
      # For each global metric, check that it is a valid value.
      for k, v in all_global_metrics.items():
          self.is_valid(v, value_name=k)
  
file_path: scenic/scenic/model_lib/base_models/tests/test_segmentation_model.py
imports: from absl.testing import absltest
  from flax import jax_utils
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.base_models import segmentation_model
label_desc: Use image node_id 4 for calling the TestSegmentationModel obj's underlying member method code with example usage: obj.test_global_metric_function() without return types