class_docstr: Torchscriptable version of `BertEmbeddings` from Huggingface transformers v2.3.0
  https://github.com/huggingface/transformers/blob/v2.3.0/transformers/modeling_bert.py # noqa
  
  Modifies the `forward` function
  
  Changes to `forward` function ::
      Typed inputs and modified device to be input_ids.device by default
class_docstr_tok: ["Torchscriptable","version","of","`","BertEmbeddings","`","from","Huggingface","transformers","v2.3.0","https",":","\/\/github.com\/huggingface\/transformers\/blob\/v2.3.0\/transformers\/modeling_bert.py","#","noqa","Modifies","the","`","forward","`","function","Changes","to","`","forward","`","function",":",":","Typed","inputs","and","modified","device","to","be","input_ids.device","by","default"]
code: def forward(
      self,
      input_ids: Tensor,
      token_type_ids: Optional[Tensor] = None,
      position_ids: Optional[Tensor] = None,
      inputs_embeds: Optional[Tensor] = None,
  ):
      if input_ids is not None:
          input_shape = input_ids.size()
      else:
          input_shape = inputs_embeds.size()[:-1]
  
      seq_length = input_shape[1]
      device = (
          inputs_embeds.device
          if inputs_embeds is not None
          else input_ids.device
      )
      if position_ids is None:
          position_ids = torch.arange(
              seq_length, dtype=torch.long, device=device
          )
          position_ids = position_ids.unsqueeze(0).expand(input_shape)
      if token_type_ids is None:
          token_type_ids = torch.zeros(
              input_shape, dtype=torch.long, device=device
          )
  
      if inputs_embeds is None:
          inputs_embeds = self.word_embeddings(input_ids)
      position_embeddings = self.position_embeddings(position_ids)
      token_type_embeddings = self.token_type_embeddings(token_type_ids)
  
      embeddings = (
          inputs_embeds + position_embeddings + token_type_embeddings
      )
      embeddings = self.LayerNorm(embeddings)
      embeddings = self.dropout(embeddings)
      return embeddings
  
imports: import math
  from typing import List, Optional, Tuple
  import torch
  from mmf.utils.patch import restore_saved_modules, safecopy_modules
  from torch import nn, Tensor
label_desc: Use image node_id 1 for calling the BertEmbeddingsJit obj's underlying member method code with example usage: obj.forward(input_ids, token_type_ids, position_ids, inputs_embeds) and returns: embeddings