code: def test_embedding_functional(self):
      a = torch.tensor([[1, 3, 2], [0, 2, 1]], dtype=torch.long)
      embeddings = torch.rand(4, 3, requires_grad=True)
  
      embed_old = torch.nn.Embedding(4, 3)
      embed_old.weight.data = embeddings.data
      # A silly test for eager, this test is useful for when we run under PYTORCH_TEST_WITH_DYNAMO=1
      # as it ensures that setattr correctly works.
      self.assertEqual(embed_old.weight.data, embeddings.data)
      res_old = embed_old(a)
  
      res_F = F.embedding(a, embeddings)
      self.assertEqual(res_old, res_F)
  
      embed_old = torch.nn.Embedding(4, 3)
      embed_old = embed_old.from_pretrained(embeddings, padding_idx=2)
      res_old = embed_old(a)
      res_F = F.embedding(a, embeddings, padding_idx=2)
  
      self.assertEqual(res_old, res_F)
  
imports: import unittest
  import random
  import itertools
  from itertools import product
  import torch
  from torch.testing._internal.common_utils import run_tests, set_default_dtype, skipIfTorchDynamo, instantiate_parametrized_tests, parametrize, _assertGradAndGradgradChecks, IS_JETSON
  from torch.testing._internal.common_cuda import TEST_CUDA
  from torch.testing._internal.common_nn import NNTestCase
  from torch.testing._internal.common_device_type import onlyNativeDeviceTypes, dtypes, instantiate_device_type_tests, dtypesIfCUDA, onlyCUDA, TEST_WITH_ROCM, skipCUDAIf, skipMeta
  import torch.nn.functional
  import torch.nn
  from torch.testing._internal.common_utils import dtype2prec_DONTUSE
label_desc: Use image node_id 11 for calling the TestEmbeddingNN obj's underlying member method code with example usage: obj.test_embedding_functional() without return types