code: def test_embedding_bag_non_contiguous_weight(self, device, dtypes):
      weight_tensor = torch.randn(3, 4, dtype=dtypes[2], device=device)
  
      weight_tensor_non_contig = weight_tensor[
          :, :3
      ]  # This is non-contiguous strided.
      weight_tensor_contig = (
          weight_tensor_non_contig.clone().contiguous()
      )  # Contig-strided.
  
      index = torch.tensor([0, 1, 2], dtype=dtypes[0], device=device)
      offsets = torch.tensor([0, 2], dtype=dtypes[1], device=device)
      for mode in ["sum", "mean", "max"]:
          output_non_contig = F.embedding_bag(
              input=index,
              weight=weight_tensor_non_contig,
              offsets=offsets,
              mode=mode,
          )
          output_contig = F.embedding_bag(
              input=index,
              weight=weight_tensor_contig,
              offsets=offsets,
              mode=mode,
          )
      self.assertEqual(output_non_contig, output_contig)
  
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 22 for calling the TestEmbeddingNNDeviceType obj's underlying member method code with example usage: obj.test_embedding_bag_non_contiguous_weight(device, dtypes) without return types