class_docstr: Embeds images and texts using the CLIP image-text model.
class_docstr_tok: ["Embeds","images","and","texts","using","the","CLIP","image-text","model","."]
docstr: Loads backbone parameters for this model from a checkpoint.
docstr_tok: ["Loads","backbone","parameters","for","this","model","from","a","checkpoint","."]
code: def load_backbone(
      self, params: Params, backbone_checkpoint_path: Optional[str]
  ) -> Params:
      """Loads backbone parameters for this model from a checkpoint."""
      del backbone_checkpoint_path  #  Redundant since we use the model variant.
  
      # This loads only the CLIP-backbone parameters, not the additional
      # parameters added by the LayerNorm above. This function is only intended
      # for initialization from pretrained CLIP checkpoints, not for loading the
      # whole model, which can be done easily in the trainer.
      loaded = clip_model.load_model_vars(self.embed_configs.variant)[
          "params"
      ]
      loaded = flax.core.unfreeze(loaded)
  
      # Remove unused parameters:
      del loaded["visual"]["proj"]
  
      # Resize positional embeddings if necessary for visual tower.
      target_size = params["clip"]["visual"][
          "positional_embedding"
      ].shape[0]
      loaded_size = loaded["visual"]["positional_embedding"].shape[0]
      if target_size != loaded_size:
          loaded["visual"][
              "positional_embedding"
          ] = utils.resize_posemb(
              loaded["visual"]["positional_embedding"], target_size
          )
  
      # Truncate positional embeddings if necessary for text tower.
      target_size = params["clip"]["text"][
          "positional_embedding"
      ].shape[0]
      loaded_size = loaded["text"]["positional_embedding"].shape[0]
      if target_size != loaded_size:
          logging.info(
              "Truncating text positional embeddigns from %s to %s",
              loaded_size,
              target_size,
          )
          loaded["text"]["positional_embedding"] = loaded["text"][
              "positional_embedding"
          ][:target_size]
  
      # Cast to float32:
      loaded = jax.tree_util.tree_map(
          lambda x: x.astype(jnp.float32)
          if x.dtype == jnp.float16
          else x,
          loaded,
      )
  
      params["clip"] = loaded
      return params
  
imports: import abc
  import functools
  from typing import Any, Callable, Dict, Optional, Tuple, Union, Sequence
  from absl import logging
  from big_vision.models import bit
  from big_vision.models import vit
  import flax
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.model_lib.base_models import box_utils
  from scenic.projects.owl_vit import utils
  from scenic.projects.owl_vit.clip import layers
  from scenic.projects.owl_vit.clip import model
label_desc: Use image node_id 2 for calling the ClipImageTextEmbedder obj's underlying member method code with example usage: obj.load_backbone(params, backbone_checkpoint_path) and returns: params