code: def test_gpu(self, coef, x, expected):
      device = "cuda" if torch.cuda.is_available() else "cpu"
      x = torch.as_tensor(x, dtype=torch.float, device=device)
      x.requires_grad = True
      coef = torch.as_tensor(coef, dtype=torch.float, device=device)
      coef.requires_grad = True
      result = polyval(coef, x)
      if coef.shape[0] > 0:  # empty coef doesn't have grad
          result.mean().backward()
          np.testing.assert_allclose(coef.grad.shape, coef.shape)
      np.testing.assert_allclose(
          result.cpu().detach().numpy(), expected
      )
  
file_path: MONAI/tests/test_polyval.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  from parameterized import parameterized
  from monai.networks.layers import polyval
label_desc: Use image node_id 2 for calling the TestPolyval obj's underlying member method code with example usage: obj.test_gpu(coef, x, expected) without return types