docstr: Tests if gradients pass though without any problems (infs, nans etc) and
  also performs gradcheck (compares numerical and analytical gradients)
docstr_tok: ["Tests","if","gradients","pass","though","without","any","problems","(","infs",",","nans","etc",")","and","also","performs","gradcheck","(","compares","numerical","and","analytical","gradients",")"]
code: def _test_gradients(self, device):
      """
      Tests if gradients pass though without any problems (infs, nans etc) and
      also performs gradcheck (compares numerical and analytical gradients)
      """
      test_random_input = self.create_random_sym3x3(device, n=16)
      test_diag_input = self.create_diag_sym3x3(device, n=16)
      test_almost_diag_input = self.create_diag_sym3x3(
          device, n=16, noise=1e-4
      )
  
      test_input = torch.cat(
          (test_random_input, test_diag_input, test_almost_diag_input)
      )
      test_input.requires_grad = True
  
      with torch.autograd.detect_anomaly():
          eigenvalues, eigenvectors = symeig3x3(
              test_input, eigenvectors=True
          )
  
          loss = eigenvalues.mean() + eigenvectors.mean()
          loss.backward()
  
      test_random_input.requires_grad = True
      # Inputs are converted to double to increase the precision of gradcheck.
      torch.autograd.gradcheck(
          symeig3x3,
          test_random_input.double(),
          eps=1e-6,
          atol=1e-2,
          rtol=1e-2,
      )
  
imports: import unittest
  import torch
  from pytorch3d.common.workaround import symeig3x3
  from pytorch3d.transforms.rotation_conversions import random_rotations
  from .common_testing import get_random_cuda_device, TestCaseMixin
label_desc: Use image node_id 18 for calling the TestSymEig3x3 obj's underlying member method code with example usage: obj._test_gradients(device) without return types