code: def test_sanity():
      class TextEmbeddings(TransformerModule, FromParams):
          def __init__(
              self,
              vocab_size: int,
              hidden_size: int,
              pad_token_id: int,
              max_position_embeddings: int,
              type_vocab_size: int,
              dropout: float,
          ):
              super().__init__()
              self.word_embeddings = torch.nn.Embedding(
                  vocab_size, hidden_size, padding_idx=pad_token_id
              )
              self.position_embeddings = torch.nn.Embedding(
                  max_position_embeddings, hidden_size
              )
              self.token_type_embeddings = torch.nn.Embedding(
                  type_vocab_size, hidden_size
              )
  
              self.layer_norm = torch.nn.LayerNorm(
                  hidden_size, eps=1e-12
              )
              self.dropout = torch.nn.Dropout(dropout)
  
          def forward(
              self,
              input_ids=None,
              token_type_ids=None,
              position_ids=None,
              inputs_embeds=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 = (
                  input_ids.device
                  if input_ids is not None
                  else inputs_embeds.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.layer_norm(embeddings)
              embeddings = self.dropout(embeddings)
              return embeddings
  
      torch.manual_seed(23)
      text = TextEmbeddings(10, 5, 2, 3, 7, 0.0)
      torch.manual_seed(23)
      transformer = TransformerEmbeddings(10, 5, 2, 3, None, 7, 0.0)
  
      input_ids = torch.tensor([[1, 2]])
      token_type_ids = torch.tensor([[1, 0]], dtype=torch.long)
      position_ids = torch.tensor([[0, 1]])
  
      text_output = text(input_ids, token_type_ids, position_ids)
      transformer_output = transformer(
          input_ids, token_type_ids, position_ids
      )
  
      assert_allclose(text_output, transformer_output)
  
imports: import copy
  import pytest
  import torch
  from torch.testing import assert_allclose
  from transformers import AutoModel
  from transformers.models.bert.configuration_bert import BertConfig
  from transformers.models.bert.modeling_bert import BertEmbeddings
  from transformers.models.albert.configuration_albert import AlbertConfig
  from transformers.models.albert.modeling_albert import AlbertEmbeddings
  from allennlp.common import Params, FromParams
  from allennlp.modules.transformer import TransformerEmbeddings, ImageFeatureEmbeddings, TransformerModule
label_desc: Use image node_id 5 for calling a global function with example usage: test_sanity() and returns: embeddings