code: def standardize_quaternion(quaternions: torch.Tensor) -> torch.Tensor:
      """
      Convert a unit quaternion to a standard form: one in which the real
      part is non negative.
  
      Args:
          quaternions: Quaternions with real part first,
              as tensor of shape (..., 4).
  
      Returns:
          Standardized quaternions as tensor of shape (..., 4).
      """
      return torch.where(
          quaternions[..., 0:1] < 0, -quaternions, quaternions
      )
  
imports: from typing import Optional
  import torch
  import torch.nn.functional
  from ..common.datatypes import Device
label_desc: Use image node_id 13 for calling a global function with example usage: standardize_quaternion(quaternions) and returns: torch