code: def test_matrix_to_quaternion_by_pi(self):
      # We check that rotations by pi around each of the 26
      # nonzero vectors containing nothing but 0, 1 and -1
      # are mapped to the right quaternions.
      # This is representative across the directions.
      options = [0.0, -1.0, 1.0]
      axes = [
          torch.tensor(vec)
          for vec in itertools.islice(  # exclude [0, 0, 0]
              itertools.product(options, options, options), 1, None
          )
      ]
  
      axes = torch.nn.functional.normalize(torch.stack(axes), dim=-1)
      # Rotation by pi around unit vector x is given by
      # the matrix 2 x x^T - Id.
      R = 2 * torch.matmul(
          axes[..., None], axes[..., None, :]
      ) - torch.eye(3)
      quats_hat = matrix_to_quaternion(R)
      R_hat = quaternion_to_matrix(quats_hat)
      self.assertClose(R, R_hat, atol=1e-3)
  
imports: import itertools
  import math
  import unittest
  from distutils.version import LooseVersion
  from typing import Optional, Union
  import numpy
  import torch
  from pytorch3d.transforms.rotation_conversions import axis_angle_to_matrix, axis_angle_to_quaternion, euler_angles_to_matrix, matrix_to_axis_angle, matrix_to_euler_angles, matrix_to_quaternion, matrix_to_rotation_6d, quaternion_apply, quaternion_multiply, quaternion_to_axis_angle, quaternion_to_matrix, random_quaternions, random_rotation, random_rotations, rotation_6d_to_matrix
  from .common_testing import TestCaseMixin
label_desc: Use image node_id 14 for calling the TestRotationConversion obj's underlying member method code with example usage: obj.test_matrix_to_quaternion_by_pi() without return types