docstr: Tests if the embeddings works as expected
  
  args:
      opt: set of options
      source_l: Length of generated input sentence
      bsize: Batchsize of generated input
docstr_tok: ["Tests","if","the","embeddings","works","as","expected","args",":","opt",":","set","of","options","source_l",":","Length","of","generated","input","sentence","bsize",":","Batchsize","of","generated","input"]
code: def embeddings_forward(self, opt, source_l=3, bsize=1):
      """
      Tests if the embeddings works as expected
  
      args:
          opt: set of options
          source_l: Length of generated input sentence
          bsize: Batchsize of generated input
      """
      vocabs = self.get_vocabs()
      emb = build_embeddings(opt, vocabs)
      test_src, _, __ = self.get_batch(source_l=source_l, bsize=bsize)
      if opt.decoder_type == "transformer":
          input = torch.cat([test_src, test_src], 1)
          res = emb(input)
          compare_to = torch.zeros(
              bsize, source_l * 2, opt.src_word_vec_size
          )
      else:
          res = emb(test_src)
          compare_to = torch.zeros(
              bsize, source_l, opt.src_word_vec_size
          )
  
      self.assertEqual(res.size(), compare_to.size())
  
file_path: OpenNMT-py/onmt/tests/test_models.py
imports: import copy
  import unittest
  import torch
  import pyonmttok
  from onmt.constants import DefaultTokens
  from collections import Counter
  import onmt
  import onmt.inputters
  import onmt.opts
  from onmt.model_builder import build_embeddings, build_encoder, build_decoder
  from onmt.utils.parse import ArgumentParser
label_desc: Use image node_id 4 for calling the TestModel obj's underlying member method code with example usage: obj.embeddings_forward(opt, source_l, bsize) without return types