code: def crop_by_transform_mat3d(
      tensor: torch.Tensor,
      transform: torch.Tensor,
      out_size: Tuple[int, int, int],
      mode: str = "bilinear",
      padding_mode: str = "zeros",
      align_corners: bool = True,
  ) -> torch.Tensor:
      """Perform crop transform on 3D volumes (5D tensor) given a perspective transformation matrix.
  
      Args:
          tensor: the 2D image tensor with shape (B, C, H, W).
          transform: a perspective transformation matrix with shape (B, 4, 4).
          out_size: size of the output image (depth, height, width).
          mode: interpolation mode to calculate output values
            ``'bilinear'`` | ``'nearest'``.
          padding_mode: padding mode for outside grid values
            ``'zeros'`` | ``'border'`` | ``'reflection'``.
          align_corners: mode for grid_generation.
  
      Returns:
          the output tensor with patches.
      """
      # simulate broadcasting
      dst_trans_src = transform.expand(tensor.shape[0], -1, -1)
  
      patches: torch.Tensor = warp_affine3d(
          tensor,
          dst_trans_src[:, :3, :],
          out_size,
          flags=mode,
          padding_mode=padding_mode,
          align_corners=align_corners,
      )
  
      return patches
  
file_path: kornia/kornia/geometry/transform/crop3d.py
imports: from typing import Tuple
  import torch
  from kornia.geometry.bbox import infer_bbox_shape3d, validate_bbox3d
  from .imgwarp import get_perspective_transform3d, warp_affine3d
label_desc: Use image node_id 4 for calling a global function with example usage: crop_by_transform_mat3d(tensor, transform, out_size, mode, padding_mode, align_corners) and returns: patches