class_docstr: Test hungarian matcher.
docstr: Tests if column==row indices for matching non-empty targets to itself.
docstr_tok: ["Tests","if","column==row","indices","for","matching","non-empty","targets","to","itself","."]
code: def test_matchers_identity(self, matcher_fn):
      """Tests if column==row indices for matching non-empty targets to itself."""
  
      # Note: you can only do this in the one hot case with targets
      # otherwise shapes don't match up.
  
      # Only use targets with non-empty boxes, otherwise
      # filtering messes up this test as it only filters the target labels
      # not the labels of the predictions.
  
      tgt_labels = []
      for i in range(self.batchsize):
          key = jax.random.PRNGKey(i)
          tgt_labels.append(
              jax.random.choice(
                  key,
                  jnp.arange(1, self.num_classes),
                  shape=(self.max_num_boxes,),
                  replace=False,
                  p=None,
              )
          )
      tgt_labels = jnp.stack(tgt_labels)
      # Ensure last target is dummy empty target.
      tgt_labels = tgt_labels.at[:, -1].set(0)
      onehot_tgt_labels = jax.nn.one_hot(tgt_labels, self.num_classes)
  
      onehot_targets = self.onehot_targets.copy()
      onehot_targets["labels"] = onehot_tgt_labels
  
      outputs = {
          "pred_probs": onehot_tgt_labels,
          "pred_boxes": onehot_targets["boxes"],
      }
  
      cost, _ = compute_cost(
          tgt_labels=tgt_labels,
          out_prob=outputs["pred_probs"],
          tgt_bbox=outputs["pred_boxes"],
          out_bbox=outputs["pred_boxes"],
          bbox_loss_coef=1.0,
          giou_loss_coef=1.0,
          class_loss_coef=1.0,
          target_is_onehot=False,
      )
  
      indices = matcher_fn(cost)
      self.assertEqual(indices.shape, (cost.shape[0], 2, cost.shape[1]))
      for row, col in indices:
          self.assertTrue(jnp.array_equal(row, col))
  
imports: from typing import Optional
  from absl.testing import absltest
  from absl.testing import parameterized
  import jax
  import jax.numpy
  import numpy
  from scenic.model_lib import matchers
  from scenic.model_lib.base_models import box_utils
  import scipy.optimize
label_desc: Use image node_id 3 for calling the MatchingTest obj's underlying member method code with example usage: obj.test_matchers_identity(matcher_fn) without return types