def normalize(q: Tensor) -> Tensor:
  _0 = __torch__.torch.nn.functional.normalize
  _1 = __torch__.pymomentum.quaternion.check(q, )
  _2 = _0(q, 2., -1, 9.9999999999999998e-13, None, )
  return _2
def rotate_vector_assume_normalized(q: Tensor,
    v: Tensor) -> Tensor:
  _3 = __torch__.pymomentum.quaternion.check(q, )
  _4 = __torch__.pymomentum.quaternion.split(q, )
  r, axis, = _4
  av = torch.cross(axis, v, -1)
  aav = torch.cross(axis, av, -1)
  _5 = torch.mul(torch.add(torch.mul(av, r), aav), 2)
  return torch.add(v, _5)
def multiply_assume_normalized(q1: Tensor,
    q2: Tensor) -> Tensor:
  _6 = __torch__.pymomentum.quaternion.check(q1, )
  _7 = __torch__.pymomentum.quaternion.check(q2, )
  x1, y1, z1, w1, = torch.unbind(q1, -1)
  x2, y2, z2, w2, = torch.unbind(q2, -1)
  _8 = torch.add(torch.mul(w1, x2), torch.mul(x1, w2))
  x = torch.sub(torch.add(_8, torch.mul(y1, z2)), torch.mul(z1, y2))
  _9 = torch.sub(torch.mul(w1, y2), torch.mul(x1, z2))
  y = torch.add(torch.add(_9, torch.mul(y1, w2)), torch.mul(z1, x2))
  _10 = torch.add(torch.mul(w1, z2), torch.mul(x1, y2))
  z = torch.add(torch.sub(_10, torch.mul(y1, x2)), torch.mul(z1, w2))
  _11 = torch.sub(torch.mul(w1, w2), torch.mul(x1, x2))
  w = torch.sub(torch.sub(_11, torch.mul(y1, y2)), torch.mul(z1, z2))
  return torch.stack([x, y, z, w], -1)
def rotate_vector(q: Tensor,
    v: Tensor) -> Tensor:
  _12 = __torch__.pymomentum.quaternion.normalize
  _13 = __torch__.pymomentum.quaternion.rotate_vector_assume_normalized
  return _13(_12(q, ), v, )
def check(q: Tensor) -> NoneType:
  _14 = "AssertionError: Quaternion should have last dimension equal to 4."
  if torch.eq(torch.size(q, -1), 4):
    pass
  else:
    ops.prim.RaiseException(_14)
  return None
def split(q: Tensor) -> Tuple[Tensor, Tensor]:
  _15 = __torch__.pymomentum.quaternion.check(q, )
  _16 = (torch.narrow(q, -1, 3, 1), torch.narrow(q, -1, 0, 3))
  return _16
