class_docstr: Tests for TextZeroShotDetectionModule.
class_docstr_tok: ["Tests","for","TextZeroShotDetectionModule","."]
docstr: Tests CLIP detection model construction and application.
docstr_tok: ["Tests","CLIP","detection","model","construction","and","application","."]
code: def test_clip_zero_shot_detection_module(self, img_size, normalize):
      """Tests CLIP detection model construction and application."""
      batch_size, num_queries, seq_len, patch_size = 8, 10, 16, 32
      side_patches = int(np.ceil(img_size / patch_size))
      body_configs = ml_collections.ConfigDict(
          dict(
              type="clip",
              variant="vit_b32",
              merge_class_token="drop",
              text_stochastic_droplayer_rate=0.1,
              vision_stochastic_droplayer_rate=0.1,
          )
      )
      images = jnp.ones((batch_size, img_size, img_size, 3))
      texts = jnp.ones(
          (batch_size, num_queries, seq_len), dtype=jnp.int32
      )
  
      model = models.TextZeroShotDetectionModule(
          body_configs, normalize=normalize
      )
  
      fn = functools.partial(model.init_with_output, train=False)
      out, variables = jax.eval_shape(
          fn, jax.random.PRNGKey(0), images, texts
      )
  
      self.assertCountEqual(variables.keys(), ["params"])
      expected_shapes = {
          "feature_map": (batch_size, side_patches, side_patches, 768),
          "pred_boxes": (batch_size, side_patches**2, 4),
          "pred_logits": (batch_size, side_patches**2, num_queries),
          "class_embeddings": (batch_size, side_patches**2, 512),
          "query_embeddings": (batch_size, num_queries, 512),
      }
      self.assertEqual(
          expected_shapes, jax.tree_util.tree_map(jnp.shape, out)
      )
  
file_path: scenic/scenic/projects/owl_vit/tests/models_test.py
imports: import functools
  from absl.testing import absltest
  from absl.testing import parameterized
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.projects.owl_vit import models
label_desc: Use image node_id 1 for calling the TextZeroShotDetectionModuleTest obj's underlying member method code with example usage: obj.test_clip_zero_shot_detection_module(img_size, normalize) without return types