class_docstr: Tests for deform_attn_sampling_fn.
class_docstr_tok: ["Tests","for","deform_attn_sampling_fn","."]
docstr: Tests handling of out-of-bounds with zero-padding.
docstr_tok: ["Tests","handling","of","out-of-bounds","with","zero-padding","."]
code: def test_bilinear_interp_out_of_bounds(self):
      """Tests handling of out-of-bounds with zero-padding."""
      im = np.ones((1, 10, 1)).astype(float)
      # Center rightmost pixel, edge rightmost pixel, way out of bounds.
      grid = np.array([[0.95, 0.5], [1.0, 0.5], [1.5, 0.5]])
      res = bilinear_interpolate(im, grid, 10, 1)
      self.assertSequenceEqual(res.shape, (3, 1))
      res = res.reshape(-1).tolist()
      self.assertSequenceEqual(res, [1.0, 0.5, 0.0])
  
file_path: scenic/scenic/projects/baselines/deformable_detr/tests/test_attention.py
imports: from absl.testing import absltest
  from absl.testing import parameterized
  import jax
  from jax import random
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.projects.baselines.deformable_detr.attention import bilinear_interpolate
  from scenic.projects.baselines.deformable_detr.attention import MultiScaleDeformableAttention
label_desc: Use image node_id 3 for calling the DeformAttnSamplingFnTest obj's underlying member method code with example usage: obj.test_bilinear_interp_out_of_bounds() without return types