class_docstr: Initial graph embedding construction class.
  
  Parameters
  ----------
  word_vocab : Vocab
      The word vocabulary.
  single_token_item : bool
      Specify whether the item (i.e., node or edge) contains single token or multiple tokens.
  emb_strategy : str
      Specify the embedding construction strategy including the following options:
          - 'w2v_bilstm': use word2vec embeddings, and apply BiLSTM encoders.
          - 'w2v_bigru': use word2vec embeddings, and apply BiGRU encoders.
          - 'w2v_bert_bilstm': use word2vec and BERT embeddings, and apply BiLSTM encoders.
          - 'w2v_bert_bigru': use word2vec and BERT embeddings, and apply BiGRU encoders.
  hidden_size : int, optional
      The hidden size of RNN layer, default: ``None``.
  num_rnn_layers : int, optional
      The number of RNN layers, default: ``1``.
  fix_word_emb : boolean, optional
      Specify whether to fix pretrained word embeddings, default: ``True``.
  fix_bert_emb : boolean, optional
      Specify whether to fix pretrained BERT embeddings, default: ``True``.
  bert_model_name : str, optional
      Specify the BERT model name, default: ``'bert-base-uncased'``.
  bert_lower_case : bool, optional
      Specify whether to lower case the input text for BERT embeddings, default: ``True``.
  word_dropout : float, optional
      Dropout ratio for word embedding, default: ``None``.
  bert_dropout : float, optional
      Dropout ratio for BERT embedding, default: ``None``.
  rnn_dropout : float, optional
      Dropout ratio for RNN embedding, default: ``None``.
docstr: Compute initial node/edge embeddings.
  
  Parameters
  ----------
  data
  
  Returns
  -------
  torch.Tensor
      The output item embeddings.
docstr_tok: ["Compute","initial","node\/edge","embeddings",".","Parameters","--","--","--","--","--","data","Returns","--","--","--","-","torch.Tensor","The","output","item","embeddings","."]
code: def forward(self, data):
      """Compute initial node/edge embeddings.
  
      Parameters
      ----------
      data
  
      Returns
      -------
      torch.Tensor
          The output item embeddings.
      """
      batch_gd = data["graph_data"]
      assert (
          batch_gd.batch_node_features["token_id"].shape[2] == 1
      ), "must be single-token node graph"
  
      ctx_length = torch.LongTensor(batch_gd._batch_num_nodes).to(
          batch_gd.device
      )
  
      # passage encoding
      token_ids = batch_gd.batch_node_features["token_id"].squeeze(2)
      encoder_embedded = self.word_emb_layers["w2v"](token_ids)
      encoder_embedded = dropout_fn(
          encoder_embedded,
          self.word_dropout,
          shared_axes=[-2],
          training=self.training,
      )
      enc_input_cat = [encoder_embedded]
  
      # answer encoding
      ans_embedded = self.word_emb_layers["w2v"](data["input_tensor2"])
      ans_embedded = dropout_fn(
          ans_embedded,
          self.word_dropout,
          shared_axes=[-2],
          training=self.training,
      )
      answer_feat = ans_embedded
  
      # Align answer info to passage at the word level
      ans_mask = data["input_tensor2"] != 0
      ctx_aware_ans_emb = self.ctx2ans_attn_l1(
          encoder_embedded, ans_embedded, ans_embedded, ans_mask
      )
      enc_input_cat.append(ctx_aware_ans_emb)
  
      if "seq_bert" in self.word_emb_layers:
          # passage encoding
          gd_list = from_batch(batch_gd)
          raw_tokens = [
              [
                  gd.node_attributes[i]["token"]
                  for i in range(gd.get_node_num())
              ]
              for gd in gd_list
          ]
          ctx_bert = self.word_emb_layers["seq_bert"](raw_tokens)
          ctx_bert = dropout_fn(
              ctx_bert,
              self.bert_dropout,
              shared_axes=[-2],
              training=self.training,
          )
          enc_input_cat.append(ctx_bert)
  
          # answer encoding
          answer_raw_tokens = data["input_text2"]
          answer_bert = self.word_emb_layers["seq_bert"](
              answer_raw_tokens
          )
          answer_bert = dropout_fn(
              answer_bert,
              self.bert_dropout,
              shared_axes=[-2],
              training=self.training,
          )
          answer_feat = torch.cat([answer_feat, answer_bert], -1)
  
      enc_input_cat = torch.cat(enc_input_cat, -1)
      ctx_feat = self.ctx_rnn_encoder(enc_input_cat, ctx_length)
      ctx_feat = (
          ctx_feat[0]
          if isinstance(ctx_feat, (tuple, list))
          else ctx_feat
      )
      answer_feat = self.ans_rnn_encoder(
          answer_feat, data["input_length2"]
      )
      answer_feat = (
          answer_feat[0]
          if isinstance(answer_feat, (tuple, list))
          else answer_feat
      )
  
      # Align answer info to passage at the word level
      enc_cat_l2 = torch.cat([encoder_embedded, ctx_feat], -1)
      ans_cat_l2 = torch.cat([ans_embedded, answer_feat], -1)
  
      if "seq_bert" in self.word_emb_layers:
          enc_cat_l2 = torch.cat([enc_cat_l2, ctx_bert], -1)
          ans_cat_l2 = torch.cat([ans_cat_l2, answer_bert], -1)
  
      ctx_aware_ans_emb = self.ctx2ans_attn_l2(
          enc_cat_l2, ans_cat_l2, answer_feat, ans_mask
      )
      ctx_feat = self.ctx_rnn_encoder_l2(
          torch.cat([ctx_feat, ctx_aware_ans_emb], -1), ctx_length
      )
      ctx_feat = (
          ctx_feat[0]
          if isinstance(ctx_feat, (tuple, list))
          else ctx_feat
      )
      batch_gd.batch_node_features["node_feat"] = ctx_feat
  
      return batch_gd
  
file_path: graph4nlp/examples/pytorch/question_generation/fused_embedding_construction.py
imports: import torch
  import torch.nn
  from graph4nlp.pytorch.data.data import from_batch
  from graph4nlp.pytorch.modules.graph_embedding_initialization.embedding_construction import BertEmbedding, EmbeddingConstructionBase, RNNEmbedding, WordEmbedding
  from graph4nlp.pytorch.modules.utils import constants
  from graph4nlp.pytorch.modules.utils.generic_utils import dropout_fn
label_desc: Use image node_id 2 for calling the FusedEmbeddingConstruction obj's underlying member method code with example usage: obj.forward(data) and returns: batch_gd