code: def depth_to_normals(
      depth: Tensor,
      camera_matrix: Tensor,
      normalize_points: bool = False,
  ) -> Tensor:
      """Compute the normal surface per pixel.
  
      Args:
          depth: image tensor containing a depth value per pixel with shape :math:`(B, 1, H, W)`.
          camera_matrix: tensor containing the camera intrinsics with shape :math:`(B, 3, 3)`.
          normalize_points: whether to normalize the pointcloud. This must be set to `True` when the depth is
          represented as the Euclidean ray length from the camera position.
  
      Return:
          tensor with a normal surface vector per pixel of the same resolution as the input :math:`(B, 3, H, W)`.
  
      Example:
          >>> depth = torch.rand(1, 1, 4, 4)
          >>> K = torch.eye(3)[None]
          >>> depth_to_normals(depth, K).shape
          torch.Size([1, 3, 4, 4])
      """
      if not isinstance(depth, Tensor):
          raise TypeError(
              f"Input depht type is not a Tensor. Got {type(depth)}."
          )
  
      if not (len(depth.shape) == 4 and depth.shape[-3] == 1):
          raise ValueError(
              f"Input depth musth have a shape (B, 1, H, W). Got: {depth.shape}"
          )
  
      if not isinstance(camera_matrix, Tensor):
          raise TypeError(
              f"Input camera_matrix type is not a Tensor. Got {type(camera_matrix)}."
          )
  
      if not (
          len(camera_matrix.shape) == 3
          and camera_matrix.shape[-2:] == (3, 3)
      ):
          raise ValueError(
              f"Input camera_matrix must have a shape (B, 3, 3). Got: {camera_matrix.shape}."
          )
  
      # compute the 3d points from depth
      xyz: Tensor = depth_to_3d(
          depth, camera_matrix, normalize_points
      )  # Bx3xHxW
  
      # compute the pointcloud spatial gradients
      gradients: Tensor = spatial_gradient(xyz)  # Bx3x2xHxW
  
      # compute normals
      a, b = gradients[:, :, 0], gradients[:, :, 1]  # Bx3xHxW
  
      normals: Tensor = torch.cross(a, b, dim=1)  # Bx3xHxW
      return kornia_ops.normalize(normals, dim=1, p=2)
  
imports: from __future__ import annotations
  from typing import Optional
  import torch
  import kornia.core
  from kornia.core import Module, Tensor, tensor
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_IS_TENSOR, KORNIA_CHECK_SHAPE
  from kornia.filters.sobel import spatial_gradient
  from kornia.utils import create_meshgrid
  from kornia.utils.helpers import deprecated
  from .camera import PinholeCamera, cam2pixel, pixel2cam, project_points, unproject_points
  from .conversions import normalize_pixel_coordinates, normalize_points_with_intrinsics
  from .linalg import compose_transformations, convert_points_to_homogeneous, inverse_transformation, transform_points
label_desc: Use image node_id 4 for calling a global function with example usage: depth_to_normals(depth, camera_matrix, normalize_points) and returns: kornia_ops