class_docstr: Test ObjectDetectionWithMatchingModel.
class_docstr_tok: ["Test","ObjectDetectionWithMatchingModel","."]
docstr: Test loss_labels by checking its output's dictionary format.
  
  Args:
    num_boxes: int; Number of boxes used for creating the flax model.
    log: bool; Whether do logging or not in labels_losses_and_metrics.
    metrics_key: list; Expected metric keys.
    focal_loss: bool; Whether to use focal loss.
docstr_tok: ["Test","loss_labels","by","checking","its","output","'s","dictionary","format",".","Args",":","num_boxes",":","int",";","Number","of","boxes","used","for","creating","the","flax","model",".","log",":","bool",";","Whether","do","logging","or","not","in","labels_losses_and_metrics",".","metrics_key",":","list",";","Expected","metric","keys",".","focal_loss",":","bool",";","Whether","to","use","focal","loss","."]
code: def test_labels_losses_and_metrics(
      self, num_boxes, log, metrics_key, focal_loss
  ):
      """Test loss_labels by checking its output's dictionary format.
  
      Args:
        num_boxes: int; Number of boxes used for creating the flax model.
        log: bool; Whether do logging or not in labels_losses_and_metrics.
        metrics_key: list; Expected metric keys.
        focal_loss: bool; Whether to use focal loss.
      """
      config = ml_collections.ConfigDict()
      config.focal_loss = focal_loss
      model = MyObjectDetectionWithMatchingModel(config=config)
      outputs, batch, indices = fake_model_outputs_batch(num_boxes)
  
      # Test loss function in the pmapped setup:
      def function_to_pmap(outputs, batch):
          return model.labels_losses_and_metrics(
              outputs, batch, indices, log
          )  # pytype: disable=wrong-arg-types  # jax-ndarray
  
      labels_lm_pmapped = jax.pmap(function_to_pmap, axis_name="batch")
  
      outputs, batch = (
          jax_utils.replicate(outputs),
          jax_utils.replicate(batch),
      )
      losses, metrics = labels_lm_pmapped(outputs, batch)
      losses = jax_utils.unreplicate(losses)
      metrics = jax_utils.unreplicate(metrics)
      self.assertSameElements(["loss_class"], losses.keys())
      self.is_valid_loss(losses["loss_class"])
      self.assertSameElements(metrics_key, metrics.keys())
      for mk in metrics_key:
          self.is_valid(metrics[mk][0])
          self.is_valid(metrics[mk][1])
  
imports: from absl.testing import absltest
  from absl.testing import parameterized
  from flax import jax_utils
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.projects.baselines.detr import detr_base_model
label_desc: Use image node_id 3 for calling the TestObjectDetectionWithMatchingModel obj's underlying member method code with example usage: obj.test_labels_losses_and_metrics(num_boxes, log, metrics_key, focal_loss) and returns: model