code: def make_upright(laf: Tensor, eps: float = 1e-9) -> Tensor:
      """Rectify the affine matrix, so that it becomes upright.
  
      Args:
          laf: :math:`(B, N, 2, 3)`
          eps: for safe division.
  
      Returns:
          laf: :math:`(B, N, 2, 3)`
  
      Example:
          >>> input = torch.ones(1, 5, 2, 3)  # BxNx2x3
          >>> output = make_upright(input)  #  BxNx2x3
      """
      KORNIA_CHECK_LAF(laf)
      det = get_laf_scale(laf)
      scale = det
      # The function is equivalent to doing 2x2 SVD and resetting rotation
      # matrix to an identity: U, S, V = svd(LAF); LAF_upright = U * S.
      b2a2 = (
          torch.sqrt(laf[..., 0:1, 1:2] ** 2 + laf[..., 0:1, 0:1] ** 2)
          + eps
      )
      laf1_ell = concatenate(
          [(b2a2 / det).contiguous(), torch.zeros_like(det)], dim=3
      )
      laf2_ell = concatenate(
          [
              (
                  (
                      laf[..., 1:2, 1:2] * laf[..., 0:1, 1:2]
                      + laf[..., 1:2, 0:1] * laf[..., 0:1, 0:1]
                  )
                  / (b2a2 * det)
              ),
              (det / b2a2).contiguous(),
          ],
          dim=3,
      )
      laf_unit_scale = concatenate(
          [concatenate([laf1_ell, laf2_ell], dim=2), laf[..., :, 2:3]],
          dim=3,
      )
      return scale_laf(laf_unit_scale, scale)
  
imports: import math
  from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from kornia.core import Tensor, concatenate, cos, sin, stack, tensor, zeros
  from kornia.core.check import KORNIA_CHECK_LAF, KORNIA_CHECK_SHAPE
  from kornia.geometry.conversions import angle_to_rotation_matrix, convert_points_from_homogeneous, rad2deg
  from kornia.geometry.linalg import transform_points
  from kornia.geometry.transform import pyrdown
label_desc: Use image node_id 8 for calling a global function with example usage: make_upright(laf, eps) and returns: scale_laf