def _interpolate_bilinear(im, rows, cols):
  """Bilinear interpolation, based on http://stackoverflow.com/a/12729229.

  Order of operations modified to match TF.

  Args:
    im: input image
    rows: floating point row coordinates of interpolation points
    cols: floating point column coordinates of interpolation points

  Returns:
    interpolated image
  """
  nrows, ncols = im.shape[-3:-1]

  col_lo = jnp.maximum(0, jnp.floor(cols).astype(jnp.int32))
  col_hi = jnp.minimum(col_lo + 1, ncols - 1)
  row_lo = jnp.maximum(0, jnp.floor(rows).astype(jnp.int32))
  row_hi = jnp.minimum(row_lo + 1, nrows - 1)

  im_a = im[..., row_lo, col_lo, :]
  im_b = im[..., row_hi, col_lo, :]
  im_c = im[..., row_lo, col_hi, :]
  im_d = im[..., row_hi, col_hi, :]

  # same order of operations as compute_lerp() in
  # https://github.com/tensorflow/tensorflow/blob/r1.15/tensorflow/core/kernels/resize_bilinear_op.cc
  x_lerp = jnp.expand_dims(cols - col_lo, -1)
  y_lerp = jnp.expand_dims(rows - row_lo, -1)
  top = im_a + (im_c - im_a) * x_lerp
  bottom = im_b + (im_d - im_b) * x_lerp
  return top + (bottom - top) * y_lerp
Bilinear interpolation, based on http://stackoverflow.com/a/12729229.

  Order of operations modified to match TF.

  Args:
    im: input image
    rows: floating point row coordinates of interpolation points
    cols: floating point column coordinates of interpolation points

  Returns:
    interpolated image
  
videogvt/train_lib/metrics_lib.py