class_docstr: Test box_iou and generalized_box_iou functions.
class_docstr_tok: ["Test","box_iou","and","generalized_box_iou","functions","."]
docstr: Tests if 0 <= IoU <= 1 and -1 <= gIoU <=1.
docstr_tok: ["Tests","if","0","<","=","IoU","<","=","1","and","-1","<","=","gIoU","<","=1","."]
code: def test_box_iou_values(self):
      """Tests if 0 <= IoU <= 1 and -1 <= gIoU <=1."""
  
      # Create fake predictions and targets
      key = jax.random.PRNGKey(0)
      key, subkey = jax.random.split(key)
      pred_bbox = sample_cxcywh_bbox(key, batch_shape=(4, 100))
      tgt_bbox = sample_cxcywh_bbox(subkey, batch_shape=(4, 63))
  
      pred_bbox = box_utils.box_cxcywh_to_xyxy(pred_bbox)
      tgt_bbox = box_utils.box_cxcywh_to_xyxy(tgt_bbox)
  
      iou, union = box_utils.box_iou(
          pred_bbox, tgt_bbox, all_pairs=True
      )
      self.assertTrue(jnp.all(iou >= 0))
      self.assertTrue(jnp.all(iou <= 1.0))
      self.assertTrue(jnp.all(union >= 0.0))
  
      giou = box_utils.generalized_box_iou(
          pred_bbox, tgt_bbox, all_pairs=True
      )
      self.assertTrue(jnp.all(giou >= -1.0))
      self.assertTrue(jnp.all(giou <= 1.0))
  
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 1 for calling the IoUTest obj's underlying member method code with example usage: obj.test_box_iou_values() without return types