code: def test_EmbeddingBag_per_sample_weights_and_no_offsets(
      self, device, dtypes
  ):
      def run_tests(mode, sparse, trainable_per_sample_weights):
          kwargs = dict(
              test_per_sample_weights=True,
              device=device,
              mode=mode,
              wdtype=dtypes[1],
              dtype=dtypes[0],
              sparse=sparse,
              trainable_per_sample_weights=trainable_per_sample_weights,
          )
  
          # Simple case
          self._test_EmbeddingBag_vs_Embedding(2, 3, 5, 7, **kwargs)
  
          # B * L > 1000
          self._test_EmbeddingBag_vs_Embedding(2, 5, 53, 23, **kwargs)
  
          # Large num_embedding
          self._test_EmbeddingBag_vs_Embedding(101, 5, 3, 7, **kwargs)
  
          # Large embedding_dim
          self._test_EmbeddingBag_vs_Embedding(2, 101, 3, 7, **kwargs)
  
      modes = ("sum",)
      sparsity = (True, False)
      trainable_scale = (True, False)
      for (
          mode,
          sparse,
          trainable_per_sample_weights,
      ) in itertools.product(modes, sparsity, trainable_scale):
          run_tests(mode, sparse, trainable_per_sample_weights)
  
      # Test CUDA Dense on half precision
      if device == "cuda":
          modes = ("sum",)
          sparsity = (False,)
          trainable_scale = (True, False)
          for (
              mode,
              sparse,
              trainable_per_sample_weights,
          ) in itertools.product(modes, sparsity, trainable_scale):
              run_tests(mode, sparse, trainable_per_sample_weights)
  
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 19 for calling the TestEmbeddingNNDeviceType obj's underlying member method code with example usage: obj.test_EmbeddingBag_per_sample_weights_and_no_offsets(device, dtypes) without return types