class_docstr: Crop random patches of a tensor image on a given size.
  
  .. image:: _static/img/RandomCrop.png
  
  Args:
      size: Desired output size (out_h, out_w) of the crop.
          Must be Tuple[int, int], then out_h = size[0], out_w = size[1].
      padding: Optional padding on each border
          of the image. Default is None, i.e no padding. If a sequence of length
          4 is provided, it is used to pad left, top, right, bottom borders
          respectively. If a sequence of length 2 is provided, it is used to
          pad left/right, top/bottom 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, reflect, replicate.
      resample: the interpolation mode.
      same_on_batch: apply the same transformation across the batch.
      align_corners: interpolation flag.
      p: probability of applying the transformation for the whole batch.
      keepdim: whether to keep the output shape the same as input (True) or broadcast it
               to the batch form (False).
      cropping_mode: The used algorithm to crop. ``slice`` will use advanced slicing to extract the tensor based
                     on the sampled indices. ``resample`` will use `warp_affine` using the affine transformation
                     to extract and resize at once. Use `slice` for efficiency, or `resample` for proper
                     differentiability.
  
  Shape:
      - Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`, Optional: :math:`(B, 3, 3)`
      - Output: :math:`(B, C, 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, 3, 3)`), then the
      applied transformation will be merged int to the input transformation tensor and returned.
  
  Examples:
      >>> import torch
      >>> _ = torch.manual_seed(0)
      >>> inputs = torch.arange(1*1*3*3.).view(1, 1, 3, 3)
      >>> aug = RandomCrop((2, 2), p=1., cropping_mode="resample")
      >>> out = aug(inputs)
      >>> out
      tensor([[[[3., 4.],
                [6., 7.]]]])
      >>> aug.inverse(out, padding_mode="replicate")
      tensor([[[[3., 4., 4.],
                [3., 4., 4.],
                [6., 7., 7.]]]])
  
  To apply the exact augmenation again, you may take the advantage of the previous parameter state:
      >>> input = torch.randn(1, 3, 32, 32)
      >>> aug = RandomCrop((2, 2), p=1., cropping_mode="resample")
      >>> (aug(input) == aug(input, params=aug._params)).all()
      tensor(True)
code: def compute_transformation(
      self,
      input: Tensor,
      params: Dict[str, Tensor],
      flags: Dict[str, Any],
  ) -> Tensor:
      if flags["cropping_mode"] in ("resample", "slice"):
          transform: Tensor = get_perspective_transform(
              params["src"].to(input), params["dst"].to(input)
          )
          return transform
      raise NotImplementedError(
          f"Not supported type: {flags['cropping_mode']}."
      )
  
imports: from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  from kornia.augmentation import random_generator
  from kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D
  from kornia.constants import Resample
  from kornia.core import Tensor, pad, tensor
  from kornia.geometry.boxes import Boxes
  from kornia.geometry.keypoints import Keypoints
  from kornia.geometry.transform import crop_by_indices, crop_by_transform_mat, get_perspective_transform
label_desc: Use image node_id 4 for calling the RandomCrop obj's underlying member method code with example usage: obj.compute_transformation(input, params, flags) and returns: transform