code: def matrix_to_rotation_6d(matrix: torch.Tensor) -> torch.Tensor:
      """
      Converts rotation matrices to 6D rotation representation by Zhou et al. [1]
      by dropping the last row. Note that 6D representation is not unique.
      Args:
          matrix: batch of rotation matrices of size (*, 3, 3)
  
      Returns:
          6D rotation representation, of size (*, 6)
  
      [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H.
      On the Continuity of Rotation Representations in Neural Networks.
      IEEE Conference on Computer Vision and Pattern Recognition, 2019.
      Retrieved from http://arxiv.org/abs/1812.07035
      """
      batch_dim = matrix.size()[:-2]
      return matrix[..., :2, :].clone().reshape(batch_dim + (6,))
  
imports: from typing import Optional
  import torch
  import torch.nn.functional
  from ..common.datatypes import Device
label_desc: Use image node_id 23 for calling a global function with example usage: matrix_to_rotation_6d(matrix) and returns: matrix