code: def test_end_to_end(self, device, dtype):
      sample = torch.full(
          (1, 2, 7, 7),
          1.0,
          requires_grad=True,
          device=device,
          dtype=dtype,
      )
      target = torch.as_tensor(
          [[[0.0, 0.0], [1.0, 1.0]]], device=device, dtype=dtype
      )
      std = torch.tensor([1.0, 1.0], device=device, dtype=dtype)
  
      hm = kornia.geometry.subpix.spatial_softmax2d(sample)
      assert_close(
          hm.sum(-1).sum(-1),
          torch.tensor([[1.0, 1.0]], device=device, dtype=dtype),
          atol=1e-4,
          rtol=1e-4,
      )
  
      pred = kornia.geometry.subpix.spatial_expectation2d(hm)
      assert_close(
          pred,
          torch.as_tensor(
              [[[0.0, 0.0], [0.0, 0.0]]], device=device, dtype=dtype
          ),
          atol=1e-4,
          rtol=1e-4,
      )
  
      loss1 = mse_loss(
          pred, target, size_average=None, reduce=None, reduction="none"
      ).mean(-1, keepdim=False)
      expected_loss1 = torch.as_tensor(
          [[0.0, 1.0]], device=device, dtype=dtype
      )
      assert_close(loss1, expected_loss1, atol=1e-4, rtol=1e-4)
  
      target_hm = kornia.geometry.subpix.render_gaussian2d(
          target, std, sample.shape[-2:]
      ).contiguous()
  
      loss2 = kornia.losses.js_div_loss_2d(
          hm, target_hm, reduction="none"
      )
      expected_loss2 = torch.as_tensor(
          [[0.0087, 0.0818]], device=device, dtype=dtype
      )
      assert_close(loss2, expected_loss2, rtol=0, atol=1e-3)
  
      loss = (loss1 + loss2).mean()
      loss.backward()
  
imports: import torch
  from torch.autograd import gradcheck
  from torch.nn.functional import mse_loss
  import kornia
  import kornia.testing
  from kornia.geometry.subpix.spatial_soft_argmax import _get_center_kernel2d, _get_center_kernel3d
  from kornia.testing import assert_close
label_desc: Use image node_id 9 for calling the TestSpatialSoftArgmax2d obj's underlying member method code with example usage: obj.test_end_to_end(device, dtype) without return types