class_docstr: Test box_iou and generalized_box_iou functions.
class_docstr_tok: ["Test","box_iou","and","generalized_box_iou","functions","."]
docstr: Use *box_iou(..., all_pairs=False) to test the all_pairs=True case.
docstr_tok: ["Use","*","box_iou","(","...",",","all_pairs=False",")","to","test","the","all_pairs=True","case","."]
code: def test_all_pairs_true_false(self, method):
      """Use *box_iou(..., all_pairs=False) to test the all_pairs=True case."""
      method_fn = self._get_method_fn(method)
  
      in1 = jnp.array(
          [  # [2, 2, 4] tensor.
              [[0.1, 0.2, 0.3, 0.4], [0.1, 0.2, 0.5, 1.0]],
              [[0.6, 0.2, 1.0, 1.0], [0.6, 0.2, 1.0, 0.8]],
          ],
          dtype=jnp.float32,
      )
      in2 = jnp.array(
          [
              [[0.4, 0.4, 0.5, 0.8], [0.4, 0.4, 0.5, 0.8]],
              [[0.7, 0.4, 0.8, 0.6], [0.1, 0.5, 0.7, 0.7]],
          ],
          dtype=jnp.float32,
      )
  
      # we will simulate all_pairs=True by manually permuting in1
      in1_1 = jnp.array(
          [  # [2, 2, 4] tensor.
              [[0.1, 0.2, 0.5, 1.0], [0.1, 0.2, 0.3, 0.4]],
              [[0.6, 0.2, 1.0, 0.8], [0.6, 0.2, 1.0, 1.0]],
          ],
          dtype=jnp.float32,
      )
  
      out = method_fn(in1, in2, all_pairs=False)  # [2, 2]
      out_1 = method_fn(in1_1, in2, all_pairs=False)  # [2, 2]
  
      # we can compare these against the output of all_pairs=True
      out_all = method_fn(in1, in2, all_pairs=True)  # [2, 2, 2]
  
      # assemble out_all_ using out and out_1. The comparisons are illustrated
      # below:
      # out     = [[0-0, 1-1], [2-2, 3-3]]
      # out_1   = [[1-0, 0-1], [3-2, 2-3]]
      # out_all = [[[0-0, 0-1], [1-0, 1-1]], [[2-2, 2-3], [3-2, 3-3]]]
      out_all_ = jnp.array(
          [
              [[out[0, 0], out_1[0, 1]], [out_1[0, 0], out[0, 1]]],
              [[out[1, 0], out_1[1, 1]], [out_1[1, 0], out[1, 1]]],
          ],
          dtype=jnp.float32,
      )
  
      self.assertSequenceAlmostEqual(
          out_all.flatten(), out_all_.flatten()
      )
  
imports: from absl.testing import absltest
  from absl.testing import parameterized
  import jax
  import jax.numpy
  import numpy
  from scenic.model_lib.base_models import box_utils
  from shapely import geometry
label_desc: Use image node_id 4 for calling the IoUTest obj's underlying member method code with example usage: obj.test_all_pairs_true_false(method) without return types