class_docstr: CoCa model.
  
  Args:
      dim (`int`):
          model dimension
      img_encoder (`nn.Module`):
          vision transformer - image encoder, returning image embeddings as (batch, seq, dim).
      image_dim (`int`):
          image embedding dimension, if not the same as model dimensions.
      num_tokens (`int`):
          number of text tokens.
      unimodal_depth (`int`):
          depth of the unimodal transformer.
      multimodal_depth (`int`):
          depth of the multimodal transformer.
      dim_head (`int`):
          dimension per attention head.
      heads (`int`):
          number of attention heads.
      caption_loss_weight (`float`):
          weight on the autoregressive caption loss.
      contrastive_loss_weight (`float`):
          weight on the contrastive loss between image and text CLS embeddings.
class_docstr_tok: ["CoCa","model",".","Args",":","dim","(","`","int","`",")",":","model","dimension","img_encoder","(","`","nn.Module","`",")",":","vision","transformer","-","image","encoder",",","returning","image","embeddings","as","(","batch",",","seq",",","dim",")",".","image_dim","(","`","int","`",")",":","image","embedding","dimension",",","if","not","the","same","as","model","dimensions",".","num_tokens","(","`","int","`",")",":","number","of","text","tokens",".","unimodal_depth","(","`","int","`",")",":","depth","of","the","unimodal","transformer",".","multimodal_depth","(","`","int","`",")",":","depth","of","the","multimodal","transformer",".","dim_head","(","`","int","`",")",":","dimension","per","attention","head",".","heads","(","`","int","`",")",":","number","of","attention","heads",".","caption_loss_weight","(","`","float","`",")",":","weight","on","the","autoregressive","caption","loss",".","contrastive_loss_weight","(","`","float","`",")",":","weight","on","the","contrastive","loss","between","image","and","text","CLS","embeddings","."]
code: def embed_image(self, images=None, image_tokens=None):
      # encode images into embeddings
      # with the img_encoder passed in at init
      # it can also accept precomputed image tokens
  
      assert not ((images is not None) and (image_tokens is not None))
  
      if images is not None:
          assert (
              self.img_encoder is not None
          ), "img_encoder must be passed in for automatic image encoding"
          image_tokens = self.img_encoder(images)
  
      # attention pool image tokens
  
      img_queries = repeat(
          self.img_queries, "n d -> b n d", b=image_tokens.shape[0]
      )
      img_queries = self.img_attn_pool(img_queries, image_tokens)
      img_queries = self.img_attn_pool_norm(img_queries)
  
      return img_queries[:, 0], img_queries[:, 1:]
  
file_path: towhee/towhee/models/coca/coca.py
imports: import torch
  from torch import einsum, nn
  import torch.nn.functional
  from einops import rearrange, repeat
  from towhee.models.layers.cross_attention import LayerNorm, Residual, RotaryEmbedding, apply_rotary_pos_emb, CrossAttention
  from towhee.models.layers.activations.swiglu import SwiGLU
label_desc: Use image node_id 3 for calling the CoCa obj's underlying member method code with example usage: obj.embed_image(images, image_tokens) and returns: img_queries,  img_queries