class_docstr: Apply a random 2D shear transformation to a tensor image.
  
  The transformation is computed so that the image center is kept invariant.
  
  Args:
      shear: Range of degrees to select from.
          If float, a shear parallel to the x axis in the range (-shear, +shear) will be applied.
          If (a, b), a shear parallel to the x axis in the range (-shear, +shear) will be applied.
          If (a, b, c, d), then x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3])
          will be applied. Will not apply shear by default.
      resample: resample mode from "nearest" (0) or "bilinear" (1).
      padding_mode: padding mode from "zeros" (0), "border" (1) or "reflection" (2).
      same_on_batch: apply the same transformation across the batch.
      align_corners: interpolation flag.
      p: probability of applying the transformation.
      keepdim: whether to keep the output shape the same as input (True) or broadcast it to the batch form (False).
  
  Shape:
      - Input: :math:`(C, H, W)` or :math:`(B, C, H, W)`
      - Output: :math:`(B, C, H, W)`
  
  .. note::
      This function internally uses :func:`kornia.geometry.transform.warp_affine`.
  
  Examples:
      >>> import torch
      >>> rng = torch.manual_seed(0)
      >>> input = torch.rand(1, 1, 3, 3)
      >>> aug = RandomShear((-5., 2., 5., 10.), p=1.)
      >>> out = aug(input)
      >>> out, aug.transform_matrix
      (tensor([[[[0.4403, 0.7614, 0.1516],
                [0.1753, 0.3074, 0.6127],
                [0.4438, 0.8924, 0.4061]]]]), tensor([[[ 1.0000,  0.0100, -0.0100],
               [-0.1183,  0.9988,  0.1194],
               [ 0.0000,  0.0000,  1.0000]]]))
      >>> aug.inverse(out)
      tensor([[[[0.4045, 0.7577, 0.1393],
                [0.2071, 0.3074, 0.5582],
                [0.3958, 0.8868, 0.4265]]]])
  
  To apply the exact augmenation again, you may take the advantage of the previous parameter state:
      >>> input = torch.randn(1, 3, 32, 32)
      >>> aug = RandomShear((-15., 20.), p=1.)
      >>> (aug(input) == aug(input, params=aug._params)).all()
      tensor(True)
class_docstr_tok: ["Apply","a","random","2D","shear","transformation","to","a","tensor","image",".","The","transformation","is","computed","so","that","the","image","center","is","kept","invariant",".","Args",":","shear",":","Range","of","degrees","to","select","from",".","If","float",",","a","shear","parallel","to","the","x","axis","in","the","range","(","-shear",",","+shear",")","will","be","applied",".","If","(","a",",","b",")",",","a","shear","parallel","to","the","x","axis","in","the","range","(","-shear",",","+shear",")","will","be","applied",".","If","(","a",",","b",",","c",",","d",")",",","then","x-axis","shear","in","(","shear","[","0","]",",","shear","[","1","]",")","and","y-axis","shear","in","(","shear","[","2","]",",","shear","[","3","]",")","will","be","applied",".","Will","not","apply","shear","by","default",".","resample",":","resample","mode","from","``","nearest","''","(","0",")","or","``","bilinear","''","(","1",")",".","padding_mode",":","padding","mode","from","``","zeros","''","(","0",")",",","``","border","''","(","1",")","or","``","reflection","''","(","2",")",".","same_on_batch",":","apply","the","same","transformation","across","the","batch",".","align_corners",":","interpolation","flag",".","p",":","probability","of","applying","the","transformation",".","keepdim",":","whether","to","keep","the","output","shape","the","same","as","input","(","True",")","or","broadcast","it","to","the","batch","form","(","False",")",".","Shape",":","-","Input",":",":","math",":","`","(","C",",","H",",","W",")","`","or",":","math",":","`","(","B",",","C",",","H",",","W",")","`","-","Output",":",":","math",":","`","(","B",",","C",",","H",",","W",")","`","..","note",":",":","This","function","internally","uses",":","func",":","`","kornia.geometry.transform.warp_affine","`",".","Examples",":",">",">",">","import","torch",">",">",">","rng","=","torch.manual_seed","(","0",")",">",">",">","input","=","torch.rand","(","1",",","1",",","3",",","3",")",">",">",">","aug","=","RandomShear","(","(","-5.",",","2.",",","5.",",","10",".",")",",","p=1",".",")",">",">",">","out","=","aug","(","input",")",">",">",">","out",",","aug.transform_matrix","(","tensor","(","[","[","[","[","0.4403",",","0.7614",",","0.1516","]",",","[","0.1753",",","0.3074",",","0.6127","]",",","[","0.4438",",","0.8924",",","0.4061","]","]","]","]",")",",","tensor","(","[","[","[","1.0000",",","0.0100",",","-0.0100","]",",","[","-0.1183",",","0.9988",",","0.1194","]",",","[","0.0000",",","0.0000",",","1.0000","]","]","]",")",")",">",">",">","aug.inverse","(","out",")","tensor","(","[","[","[","[","0.4045",",","0.7577",",","0.1393","]",",","[","0.2071",",","0.3074",",","0.5582","]",",","[","0.3958",",","0.8868",",","0.4265","]","]","]","]",")","To","apply","the","exact","augmenation","again",",","you","may","take","the","advantage","of","the","previous","parameter","state",":",">",">",">","input","=","torch.randn","(","1",",","3",",","32",",","32",")",">",">",">","aug","=","RandomShear","(","(","-15.",",","20",".",")",",","p=1",".",")",">",">",">","(","aug","(","input",")","==","aug","(","input",",","params=aug._params",")",")",".all","(",")","tensor","(","True",")"]
code: def __init__(
      self,
      shear: Union[
          Tensor,
          float,
          Tuple[float, float],
          Tuple[float, float, float, float],
      ],
      resample: Union[str, int, Resample] = Resample.BILINEAR.name,
      same_on_batch: bool = False,
      align_corners: bool = False,
      padding_mode: Union[
          str, int, SamplePadding
      ] = SamplePadding.ZEROS.name,
      p: float = 0.5,
      keepdim: bool = False,
  ) -> None:
      super().__init__(
          p=p, same_on_batch=same_on_batch, keepdim=keepdim
      )
      self._param_generator: rg.ShearGenerator = rg.ShearGenerator(
          shear
      )
      self.flags = {
          "resample": Resample.get(resample),
          "padding_mode": SamplePadding.get(padding_mode),
          "align_corners": align_corners,
      }
  
file_path: kornia/kornia/augmentation/_2d/geometric/shear.py
imports: from typing import Any, Dict, Optional, Tuple, Union
  from kornia.augmentation import random_generator
  from kornia.augmentation._2d.geometric.base import GeometricAugmentationBase2D
  from kornia.constants import Resample, SamplePadding
  from kornia.core import Tensor, as_tensor
  from kornia.geometry.conversions import deg2rad
  from kornia.geometry.transform import get_shear_matrix2d, warp_affine
label_desc: Use image node_id 1 to create a new RandomShear object from inherited base classes: GeometricAugmentationBase2D with example: obj = RandomShear(shear, resample, same_on_batch, align_corners, padding_mode, p, keepdim)