class_docstr: This module encodes two modalities separately, and performs bi-directional
  attention using a connection layer. It is based on the modified BertEncoder in
  the paper: [ViLBERT: Pretraining Task-Agnostic Visiolinguistic Representations
  for Vision-and-Language Tasks](https://api.semanticscholar.org/CorpusID:199453025)
  
  # Parameters
  
  num_hidden_layers1: `int` (default = `12`)
      Number of hidden layers in the transformer block for the first modality.
  num_hidden_layers2: `int` (default = `12`)
      Number of hidden layers in the transformer block for the second modality.
  hidden_size1: `int` (default = `1024`)
  hidden_size2: `int` (default = `1024`)
  combined_hidden_size: `int` (default = `1024`)
      Hidden size for the connection layer.
  intermediate_size1: `int` (default = `1024`)
  intermediate_size2: `int` (default = `1024`)
  num_attention_heads1: `int` (default = `8`)
  num_attention_heads2: `int` (default = `8`)
  combined_num_attention_heads: `int` (default = `8`)
      Number of attention heads in the connection layer.
  attention_dropout1: `float` (default = `0.1`)
  hidden_dropout1: `float` (default = `0.1`)
  attention_dropout2: `float` (default = `0.1`)
  hidden_dropout2: `float` (default = `0.1`)
  biattention_id1: `List`, optional (default = `[1]`)
  biattention_id2: `List`, optional (default = `[1]`)
  fixed_layer1: `int` (default = `0`)
  fixed_layer2: `int` (default = `0`)
  fast_mode: `bool` (default = `False`)
  with_coattention: `bool` (default = `True`)
  in_batch_pairs: `bool` (default = `False`)
class_docstr_tok: ["This","module","encodes","two","modalities","separately",",","and","performs","bi-directional","attention","using","a","connection","layer",".","It","is","based","on","the","modified","BertEncoder","in","the","paper",":","[","ViLBERT",":","Pretraining","Task-Agnostic","Visiolinguistic","Representations","for","Vision-and-Language","Tasks","]","(","https",":","\/\/api.semanticscholar.org\/CorpusID:199453025",")","#","Parameters","num_hidden_layers1",":","`","int","`","(","default","=","`","12","`",")","Number","of","hidden","layers","in","the","transformer","block","for","the","first","modality",".","num_hidden_layers2",":","`","int","`","(","default","=","`","12","`",")","Number","of","hidden","layers","in","the","transformer","block","for","the","second","modality",".","hidden_size1",":","`","int","`","(","default","=","`","1024","`",")","hidden_size2",":","`","int","`","(","default","=","`","1024","`",")","combined_hidden_size",":","`","int","`","(","default","=","`","1024","`",")","Hidden","size","for","the","connection","layer",".","intermediate_size1",":","`","int","`","(","default","=","`","1024","`",")","intermediate_size2",":","`","int","`","(","default","=","`","1024","`",")","num_attention_heads1",":","`","int","`","(","default","=","`","8","`",")","num_attention_heads2",":","`","int","`","(","default","=","`","8","`",")","combined_num_attention_heads",":","`","int","`","(","default","=","`","8","`",")","Number","of","attention","heads","in","the","connection","layer",".","attention_dropout1",":","`","float","`","(","default","=","`","0.1","`",")","hidden_dropout1",":","`","float","`","(","default","=","`","0.1","`",")","attention_dropout2",":","`","float","`","(","default","=","`","0.1","`",")","hidden_dropout2",":","`","float","`","(","default","=","`","0.1","`",")","biattention_id1",":","`","List","`",",","optional","(","default","=","`","[","1","]","`",")","biattention_id2",":","`","List","`",",","optional","(","default","=","`","[","1","]","`",")","fixed_layer1",":","`","int","`","(","default","=","`","0","`",")","fixed_layer2",":","`","int","`","(","default","=","`","0","`",")","fast_mode",":","`","bool","`","(","default","=","`","False","`",")","with_coattention",":","`","bool","`","(","default","=","`","True","`",")","in_batch_pairs",":","`","bool","`","(","default","=","`","False","`",")"]
code: def _from_config(cls, config: "PretrainedConfig", **kwargs):
      final_kwargs = {}
      final_kwargs["num_hidden_layers1"] = config.num_hidden_layers
      final_kwargs["hidden_size1"] = config.hidden_size
      final_kwargs["num_attention_heads1"] = config.num_attention_heads
      final_kwargs[
          "attention_dropout1"
      ] = config.attention_probs_dropout_prob
      final_kwargs["hidden_dropout1"] = config.hidden_dropout_prob
      final_kwargs["intermediate_size1"] = config.intermediate_size
      final_kwargs["activation"] = config.hidden_act
      final_kwargs.update(**kwargs)
      return cls(**final_kwargs)
  
file_path: allennlp/allennlp/modules/transformer/bimodal_encoder.py
imports: from typing import Optional, List, TYPE_CHECKING
  import torch
  from allennlp.common import FromParams
  from allennlp.modules.util import replicate_layers
  from allennlp.modules.transformer.transformer_layer import TransformerLayer
  from allennlp.modules.transformer.bimodal_connection_layer import BiModalConnectionLayer
  from allennlp.modules.transformer.transformer_module import TransformerModule
label_desc: Use image node_id 3 for calling the BiModalEncoder obj's underlying member method code with example usage: obj._from_config(cls, config) and returns: cls