docstr: Tests whether the `so3_log_map` is robust to the input matrices
  who's rotation angles are close to the numerically unstable region
  (i.e. matrices with low rotation angles).
docstr_tok: ["Tests","whether","the","`","so3_log_map","`","is","robust","to","the","input","matrices","who","'s","rotation","angles","are","close","to","the","numerically","unstable","region","(","i.e",".","matrices","with","low","rotation","angles",")","."]
code: def test_so3_log_singularity(self, batch_size: int = 100):
      """
      Tests whether the `so3_log_map` is robust to the input matrices
      who's rotation angles are close to the numerically unstable region
      (i.e. matrices with low rotation angles).
      """
      # generate random rotations with a tiny angle
      device = torch.device("cuda:0")
      identity = torch.eye(3, device=device)
      rot180 = identity * torch.tensor(
          [[1.0, -1.0, -1.0]], device=device
      )
      r = [identity, rot180]
      # add random rotations and random almost orthonormal matrices
      r.extend(
          [
              torch.linalg.qr(
                  identity + torch.randn_like(identity) * 1e-4
              )[0]
              + float(i > batch_size // 2)
              * (0.5 - torch.rand_like(identity))
              * 1e-3
              # this adds random noise to the second half
              # of the random orthogonal matrices to generate
              # near-orthogonal matrices
              for i in range(batch_size - 2)
          ]
      )
      r = torch.stack(r)
      r.requires_grad = True
      # the log of the rotation matrix r
      r_log = so3_log_map(r, cos_bound=1e-4, eps=1e-2)
      # tests whether all outputs are finite
      self.assertTrue(torch.isfinite(r_log).all())
      # tests whether the gradient is not None and all finite
      loss = r.sum()
      loss.backward()
      self.assertIsNotNone(r.grad)
      self.assertTrue(torch.isfinite(r.grad).all())
  
imports: import math
  import unittest
  from distutils.version import LooseVersion
  import numpy
  import torch
  from pytorch3d.transforms.so3 import hat, so3_exp_map, so3_log_map, so3_relative_angle, so3_rotation_angle
  from .common_testing import TestCaseMixin
label_desc: Use image node_id 8 for calling the TestSO3 obj's underlying member method code with example usage: obj.test_so3_log_singularity(batch_size) without return types