code: def intersect_rbox_edges(
      corners1: jnp.ndarray, corners2: jnp.ndarray
  ) -> jnp.ndarray:
      """Find intersection points between all four edges of both rotated boxes.
  
      Note that you are expected to explicitly use vmap to control batching.
  
      Args:
        corners1: (4, 2)-ndarray of corners for rbox1.
        corners2: (4, 2)-ndarray of corners for rbox2.
  
      Returns:
        intersections: (4, 4, 2)-ndarray (i, j, :) means intersection of i-th
        edge of rbox1 with j-th of rbox2.
      """
      intersections = []
      # Apparently for-loop is 2-4x faster than vectorized implementation on TPU
      # because it has much higher memory bandwidth. On GPU, the for-loop
      # implementation is 1.5x slower than vectorized.
      for i in range(4):
          line1 = jnp.stack(
              [corners1[i, :], corners1[(i + 1) % 4, :]], axis=0
          )
          for j in range(4):
              line2 = jnp.stack(
                  [corners2[j, :], corners2[(j + 1) % 4, :]], axis=0
              )
              intersections.append(
                  intersect_line_segments(line1, line2)
              )
      intersections = jnp.reshape(jnp.stack(intersections), (4, 4, 2))
      return intersections
  
file_path: scenic/scenic/model_lib/base_models/box_utils.py
imports: from typing import Any, Union
  import jax.numpy
  import numpy
label_desc: Use image node_id 10 for calling a global function with example usage: intersect_rbox_edges(corners1, corners2) and returns: intersections