code: def from_matrix(cls, mat):
      assert isinstance(mat, np.ndarray)
      if mat.shape == (3, 3):
          id_mat = np.eye(4)
          id_mat[0:3, 0:3] = mat
          mat = id_mat
      assert mat.shape == (4, 4)
      quat = transformations.quaternion_from_matrix(mat).astype(
          np.float32
      )
      return cls(quat)
  
imports: import numpy
  from geometry import transformations
label_desc: Use image node_id 3 for calling the Rotation obj's underlying member method code with example usage: obj.from_matrix(cls, mat) and returns: cls