class_docstr: Apply random crop on 3D volumes (5D tensor).
  
  Crops random sub-volumes on a given size.
  
  Args:
      p: probability of applying the transformation for the whole batch.
      size: Desired output size (out_d, out_h, out_w) of the crop.
          Must be Tuple[int, int, int], then out_d = size[0], out_h = size[1], out_w = size[2].
      padding: Optional padding on each border of the image.
          Default is None, i.e no padding. If a sequence of length 6 is provided, it is used to pad
          left, top, right, bottom, front, back borders respectively.
          If a sequence of length 3 is provided, it is used to pad left/right,
          top/bottom, front/back borders, respectively.
      pad_if_needed: It will pad the image if smaller than the
          desired size to avoid raising an exception. Since cropping is done
          after padding, the padding seems to be done at a random offset.
      fill: Pixel fill value for constant fill. Default is 0. If a tuple of
          length 3, it is used to fill R, G, B channels respectively.
          This value is only used when the padding_mode is constant.
      padding_mode: Type of padding. Should be: constant, edge, reflect or symmetric. Default is constant.
      resample: resample mode from "nearest" (0) or "bilinear" (1).
      same_on_batch: apply the same transformation across the batch.
      align_corners: interpolation flag.
      keepdim: whether to keep the output shape the same as input (True) or broadcast it
        to the batch form (False).
  
  Shape:
      - Input: :math:`(C, D, H, W)` or :math:`(B, C, D, H, W)`, Optional: :math:`(B, 4, 4)`
      - Output: :math:`(B, C, , out_d, out_h, out_w)`
  
  Note:
      Input tensor must be float and normalized into [0, 1] for the best differentiability support.
      Additionally, this function accepts another transformation tensor (:math:`(B, 4, 4)`), then the
      applied transformation will be merged int to the input transformation tensor and returned.
  
  Examples:
      >>> import torch
      >>> rng = torch.manual_seed(0)
      >>> inputs = torch.randn(1, 1, 3, 3, 3)
      >>> aug = RandomCrop3D((2, 2, 2), p=1.)
      >>> aug(inputs)
      tensor([[[[[-1.1258, -1.1524],
                 [-0.4339,  0.8487]],
      <BLANKLINE>
                [[-1.2633,  0.3500],
                 [ 0.1665,  0.8744]]]]])
  
  To apply the exact augmenation again, you may take the advantage of the previous parameter state:
      >>> input = torch.rand(1, 3, 32, 32, 32)
      >>> aug = RandomCrop3D((24, 24, 24), p=1.)
      >>> (aug(input) == aug(input, params=aug._params)).all()
      tensor(True)
class_docstr_tok: ["Apply","random","crop","on","3D","volumes","(","5D","tensor",")",".","Crops","random","sub-volumes","on","a","given","size",".","Args",":","p",":","probability","of","applying","the","transformation","for","the","whole","batch",".","size",":","Desired","output","size","(","out_d",",","out_h",",","out_w",")","of","the","crop",".","Must","be","Tuple","[","int",",","int",",","int","]",",","then","out_d","=","size","[","0","]",",","out_h","=","size","[","1","]",",","out_w","=","size","[","2","]",".","padding",":","Optional","padding","on","each","border","of","the","image",".","Default","is","None",",","i.e","no","padding",".","If","a","sequence","of","length","6","is","provided",",","it","is","used","to","pad","left",",","top",",","right",",","bottom",",","front",",","back","borders","respectively",".","If","a","sequence","of","length","3","is","provided",",","it","is","used","to","pad","left\/right",",","top\/bottom",",","front\/back","borders",",","respectively",".","pad_if_needed",":","It","will","pad","the","image","if","smaller","than","the","desired","size","to","avoid","raising","an","exception",".","Since","cropping","is","done","after","padding",",","the","padding","seems","to","be","done","at","a","random","offset",".","fill",":","Pixel","fill","value","for","constant","fill",".","Default","is","0",".","If","a","tuple","of","length","3",",","it","is","used","to","fill","R",",","G",",","B","channels","respectively",".","This","value","is","only","used","when","the","padding_mode","is","constant",".","padding_mode",":","Type","of","padding",".","Should","be",":","constant",",","edge",",","reflect","or","symmetric",".","Default","is","constant",".","resample",":","resample","mode","from","``","nearest","''","(","0",")","or","``","bilinear","''","(","1",")",".","same_on_batch",":","apply","the","same","transformation","across","the","batch",".","align_corners",":","interpolation","flag",".","keepdim",":","whether","to","keep","the","output","shape","the","same","as","input","(","True",")","or","broadcast","it","to","the","batch","form","(","False",")",".","Shape",":","-","Input",":",":","math",":","`","(","C",",","D",",","H",",","W",")","`","or",":","math",":","`","(","B",",","C",",","D",",","H",",","W",")","`",",","Optional",":",":","math",":","`","(","B",",","4",",","4",")","`","-","Output",":",":","math",":","`","(","B",",","C",",",",","out_d",",","out_h",",","out_w",")","`","Note",":","Input","tensor","must","be","float","and","normalized","into","[","0",",","1","]","for","the","best","differentiability","support",".","Additionally",",","this","function","accepts","another","transformation","tensor","(",":","math",":","`","(","B",",","4",",","4",")","`",")",",","then","the","applied","transformation","will","be","merged","int","to","the","input","transformation","tensor","and","returned",".","Examples",":",">",">",">","import","torch",">",">",">","rng","=","torch.manual_seed","(","0",")",">",">",">","inputs","=","torch.randn","(","1",",","1",",","3",",","3",",","3",")",">",">",">","aug","=","RandomCrop3D","(","(","2",",","2",",","2",")",",","p=1",".",")",">",">",">","aug","(","inputs",")","tensor","(","[","[","[","[","[","-1.1258",",","-1.1524","]",",","[","-0.4339",",","0.8487","]","]",",","<","BLANKLINE",">","[","[","-1.2633",",","0.3500","]",",","[","0.1665",",","0.8744","]","]","]","]","]",")","To","apply","the","exact","augmenation","again",",","you","may","take","the","advantage","of","the","previous","parameter","state",":",">",">",">","input","=","torch.rand","(","1",",","3",",","32",",","32",",","32",")",">",">",">","aug","=","RandomCrop3D","(","(","24",",","24",",","24",")",",","p=1",".",")",">",">",">","(","aug","(","input",")","==","aug","(","input",",","params=aug._params",")",")",".all","(",")","tensor","(","True",")"]
code: def apply_transform(
      self,
      input: Tensor,
      params: Dict[str, Tensor],
      flags: Dict[str, Any],
      transform: Optional[Tensor] = None,
  ) -> Tensor:
      if not isinstance(transform, Tensor):
          raise TypeError(
              f"Expected the transform to be a Tensor. Gotcha {type(transform)}"
          )
  
      return crop_by_transform_mat3d(
          input,
          transform,
          flags["size"],
          mode=flags["resample"].name.lower(),
          align_corners=flags["align_corners"],
      )
  
file_path: kornia/kornia/augmentation/_3d/geometric/crop.py
imports: from typing import Any, Dict, Optional, Tuple, Union
  from kornia.augmentation import random_generator
  from kornia.augmentation._3d.geometric.base import GeometricAugmentationBase3D
  from kornia.constants import Resample
  from kornia.core import Tensor, pad
  from kornia.geometry import crop_by_transform_mat3d, get_perspective_transform3d
label_desc: Use image node_id 4 for calling the RandomCrop3D obj's underlying member method code with example usage: obj.apply_transform(input, params, flags, transform) and returns: crop_by_transform_mat3d