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","."]
code: def __init__(
      self,
      max_text_len: int = 256,
      log_scale: Optional[Union[str, float]] = None,
      bias: bool = False,
  ):
      super().__init__()
      self.max_text_len = max_text_len
      self.log_scale = log_scale
      if isinstance(log_scale, float):
          self.log_scale = nn.Parameter(
              torch.Tensor([float(log_scale)]), requires_grad=True
          )
      elif log_scale not in ["auto", "none", None]:
          raise ValueError(
              f"log_scale should be one of "
              f'"auto", "none", None, but got {log_scale}'
          )
  
      self.bias = None
      if bias:
          bias_value = -math.log((1 - 0.01) / 0.01)
          self.bias = nn.Parameter(
              torch.Tensor([bias_value]), requires_grad=True
          )
  
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 1 to create a new ContrastiveEmbed object from inherited base classes: nn with example: obj = ContrastiveEmbed(max_text_len, log_scale, bias)