class_docstr: Bi-Encoder model component. Encapsulates query/question and context/passage encoders.
      
code: def __init__(
      self,
      UniterEncoder: nn.Module,
      BertEncoder: nn.Module,
      args: Any,  # pylint: disable=invalid-name
      fix_img_encoder: bool = False,
      fix_txt_encoder: bool = False,
      project_dim: int = 0,
  ):
      super().__init__()
      if args.img_model_type == "uniter-base":
          self.img_model = UniterEncoder.init_encoder(
              args.img_model_config,
              checkpoint_path=args.img_checkpoint,
              project_dim=project_dim,
          )
      else:
          raise ValueError(
              f"image encoder does not support other types ({args.img_model_type}) for now"
          )
  
      if args.txt_model_type == "bert-base":
          self.txt_model = BertEncoder.init_encoder(
              args.txt_model_config,
              checkpoint_path=args.txt_checkpoint,
              project_dim=project_dim,
          )
      elif args.txt_model_type == "uniter-base":
          self.txt_model = UniterEncoder.init_encoder(
              args.txt_model_config,
              checkpoint_path=args.txt_checkpoint,
              project_dim=project_dim,
          )
      else:
          raise ValueError(
              f"txt encoder does not support other types ({args.txt_model_type}) for now"
          )
  
      self.fix_img_encoder = fix_img_encoder
      self.fix_txt_encoder = fix_txt_encoder
      self.project_dim = project_dim
      if fix_txt_encoder:
          for param in self.txt_model.parameters():
              param.requires_grad = False
      if fix_img_encoder:
          for param in self.img_model.parameters():
              param.requires_grad = False
  
file_path: towhee/towhee/models/lightning_dot/bi_encoder.py
imports: from typing import Any
  import torch
  from collections import defaultdict
  from torch import nn
label_desc: Use image node_id 1 to create a new BiEncoder object from inherited base classes: nn with example: obj = BiEncoder(UniterEncoder, BertEncoder, args, fix_img_encoder, fix_txt_encoder, project_dim)