code: def test_embedding_max_norm_fwd_AD(self, device, dtype):
      if torch.device(device).type == "xla":
          self.skipTest("forward AD doesn't work on xla")
  
      # can't use gradcheck since in place renorm makes analytical gradients different from produced ones
      weight = torch.randn((4, 4), device=device, dtype=dtype) * 2
      tangent = torch.ones((4, 4), device=device, dtype=dtype)
      inp = torch.tensor([[0, 1], [2, 2]], device=device)
      with torch.autograd.forward_ad.dual_level():
          dual_weight = torch.autograd.forward_ad.make_dual(
              weight, tangent
          )
          out = nn.functional.embedding(inp, dual_weight, max_norm=1.0)
          jvp = torch.autograd.forward_ad.unpack_dual(out).tangent
  
      expected_grad = torch.ones((2, 2, 4), device=device, dtype=dtype)
      self.assertEqual(jvp, expected_grad)
  
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 5 for calling the TestEmbeddingNNDeviceType obj's underlying member method code with example usage: obj.test_embedding_max_norm_fwd_AD(device, dtype) without return types