docstr: x has shape [batch, seq length]
docstr_tok: ["x","has","shape","[","batch",",","seq","length","]"]
code: def forward(self, x):
      """x has shape [batch, seq length]"""
  
      padding_mask = x == self.tokenizer.vocab["[PAD]"]
  
      x = x.transpose(0, 1).contiguous()
  
      positions = torch.arange(len(x), device=x.device).unsqueeze(-1)
      h = self.tokens_embeddings(x)
      h = h + self.position_embeddings(positions).expand_as(h)
      h = self.dropout(h)
  
      attn_mask = None
      if self.causal:
          attn_mask = torch.full(
              (len(x), len(x)),
              -float("Inf"),
              device=h.device,
              dtype=h.dtype,
          )
          attn_mask = torch.triu(attn_mask, diagonal=1)
  
      for (
          layer_norm_1,
          attention,
          adapter_1,
          layer_norm_2,
          feed_forward,
          adapter_2,
      ) in zip(
          self.layer_norms_1,
          self.attentions,
          self.adapters_1,
          self.layer_norms_2,
          self.feed_forwards,
          self.adapters_2,
      ):
          h = layer_norm_1(h)
          x, _ = attention(
              h,
              h,
              h,
              attn_mask=attn_mask,
              need_weights=False,
              key_padding_mask=padding_mask,
          )
          x = self.dropout(x)
  
          x = (
              adapter_1(x) + x
          )  # Add an adapter with a skip-connection after attention module
  
          h = x + h
  
          h = layer_norm_2(h)
          x = feed_forward(h)
          x = self.dropout(x)
  
          x = (
              adapter_2(x) + x
          )  # Add an adapter with a skip-connection after feed-forward module
  
          h = x + h
      return h
  
imports: import torch
  from pytorch_pretrained_bert import BertTokenizer
  from transfer_nlp.plugins.config import register_plugin
label_desc: Use image node_id 2 for calling the TransformerWithAdapters obj's underlying member method code with example usage: obj.forward(x) and returns: h