class_docstr: text visual ContrastiveEmbed layer.
  
  Args:
      max_text_len (int, optional): Maximum length of text.
      log_scale (Optional[Union[str, float]]):  The initial value of a
        learnable parameter to multiply with the similarity
        matrix to normalize the output.  Defaults to 0.0.
        - If set to 'auto', the similarity matrix will be normalized by
          a fixed value ``sqrt(d_c)`` where ``d_c`` is the channel number.
        - If set to 'none' or ``None``, there is no normalization applied.
        - If set to a float number, the similarity matrix will be multiplied
          by ``exp(log_scale)``, where ``log_scale`` is learnable.
      bias (bool, optional): Whether to add bias to the output.
        If set to ``True``, a learnable bias that is initialized as -4.6
        will be added to the output. Useful when training from scratch.
        Defaults to False.
class_docstr_tok: ["text","visual","ContrastiveEmbed","layer",".","Args",":","max_text_len","(","int",",","optional",")",":","Maximum","length","of","text",".","log_scale","(","Optional","[","Union","[","str",",","float","]","]",")",":","The","initial","value","of","a","learnable","parameter","to","multiply","with","the","similarity","matrix","to","normalize","the","output",".","Defaults","to","0.0",".","-","If","set","to","'auto","'",",","the","similarity","matrix","will","be","normalized","by","a","fixed","value","``","sqrt","(","d_c",")","``","where","``","d_c","``","is","the","channel","number",".","-","If","set","to","'none","'","or","``","None","``",",","there","is","no","normalization","applied",".","-","If","set","to","a","float","number",",","the","similarity","matrix","will","be","multiplied","by","``","exp","(","log_scale",")","``",",","where","``","log_scale","``","is","learnable",".","bias","(","bool",",","optional",")",":","Whether","to","add","bias","to","the","output",".","If","set","to","``","True","``",",","a","learnable","bias","that","is","initialized","as","-4.6","will","be","added","to","the","output",".","Useful","when","training","from","scratch",".","Defaults","to","False","."]
docstr: Forward function.
  
  Args:
      visual_feat (Tensor): Visual features.
      text_feat (Tensor): Text features.
      text_token_mask (Tensor): A mask used for text feats.
  
  Returns:
      Tensor: Classification score.
docstr_tok: ["Forward","function",".","Args",":","visual_feat","(","Tensor",")",":","Visual","features",".","text_feat","(","Tensor",")",":","Text","features",".","text_token_mask","(","Tensor",")",":","A","mask","used","for","text","feats",".","Returns",":","Tensor",":","Classification","score","."]
code: def forward(
      self,
      visual_feat: Tensor,
      text_feat: Tensor,
      text_token_mask: Tensor,
  ) -> Tensor:
      """Forward function.
  
      Args:
          visual_feat (Tensor): Visual features.
          text_feat (Tensor): Text features.
          text_token_mask (Tensor): A mask used for text feats.
  
      Returns:
          Tensor: Classification score.
      """
      res = visual_feat @ text_feat.transpose(-1, -2)
      if isinstance(self.log_scale, nn.Parameter):
          res = res * self.log_scale.exp()
      elif self.log_scale == "auto":
          # NOTE: similar to the normalizer in self-attention
          res = res / math.sqrt(visual_feat.shape[-1])
      if self.bias is not None:
          res = res + self.bias
      res.masked_fill_(~text_token_mask[:, None, :], float("-inf"))
  
      new_res = torch.full(
          (*res.shape[:-1], self.max_text_len),
          float("-inf"),
          device=res.device,
      )
      new_res[..., : res.shape[-1]] = res
  
      return new_res
  
imports: import copy
  import math
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  import torch.nn
  from mmcv.cnn import Linear
  from mmengine.model import constant_init
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.models.losses import QualityFocalLoss
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox_cxcywh_to_xyxy, bbox_xyxy_to_cxcywh
  from mmdet.utils import InstanceList, reduce_mean
  from ..layers import inverse_sigmoid
  from .atss_vlfusion_head import convert_grounding_to_cls_scores
  from .dino_head import DINOHead
label_desc: Use image node_id 2 for calling the ContrastiveEmbed obj's underlying member method code with example usage: obj.forward(visual_feat, text_feat, text_token_mask) and returns: new_res