class_docstr: Apply a random 2D affine transformation to a tensor image.
  
  Args:
      translate_x: tuple of maximum absolute fraction for horizontal translations.
          For example translate_x=(a, b), then horizontal shift
          is randomly sampled in the range img_width * a < dx < img_width * b
      translate_y: tuple of maximum absolute fraction for vertical translations.
          For example translate_y=(a, b), then vertical shift
          is randomly sampled in the range img_height * a < dy < img_height * b.
      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 = RandomTranslate((-0.2, 0.2), (-0.1, 0.1), p=1.)
      >>> out = aug(input)
      >>> out, aug.transform_matrix
      (tensor([[[[0.3403, 0.6439, 0.2920],
                [0.1377, 0.3383, 0.5569],
                [0.3226, 0.6909, 0.4844]]]]), tensor([[[ 1.0000,  0.0000,  0.1588],
               [ 0.0000,  1.0000, -0.0907],
               [ 0.0000,  0.0000,  1.0000]]]))
      >>> aug.inverse(out)
      tensor([[[[0.3565, 0.4839, 0.1922],
                [0.2164, 0.4134, 0.3968],
                [0.3797, 0.6075, 0.3765]]]])
  
  To apply the exact augmenation again, you may take the advantage of the previous parameter state:
      >>> input = torch.randn(1, 3, 32, 32)
      >>> aug = RandomTranslate((-0.2, 0.2), (-0.1, 0.1), p=1.)
      >>> (aug(input) == aug(input, params=aug._params)).all()
      tensor(True)
class_docstr_tok: ["Apply","a","random","2D","affine","transformation","to","a","tensor","image",".","Args",":","translate_x",":","tuple","of","maximum","absolute","fraction","for","horizontal","translations",".","For","example","translate_x=","(","a",",","b",")",",","then","horizontal","shift","is","randomly","sampled","in","the","range","img_width","*","a","<","dx","<","img_width","*","b","translate_y",":","tuple","of","maximum","absolute","fraction","for","vertical","translations",".","For","example","translate_y=","(","a",",","b",")",",","then","vertical","shift","is","randomly","sampled","in","the","range","img_height","*","a","<","dy","<","img_height","*","b.","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","=","RandomTranslate","(","(","-0.2",",","0.2",")",",","(","-0.1",",","0.1",")",",","p=1",".",")",">",">",">","out","=","aug","(","input",")",">",">",">","out",",","aug.transform_matrix","(","tensor","(","[","[","[","[","0.3403",",","0.6439",",","0.2920","]",",","[","0.1377",",","0.3383",",","0.5569","]",",","[","0.3226",",","0.6909",",","0.4844","]","]","]","]",")",",","tensor","(","[","[","[","1.0000",",","0.0000",",","0.1588","]",",","[","0.0000",",","1.0000",",","-0.0907","]",",","[","0.0000",",","0.0000",",","1.0000","]","]","]",")",")",">",">",">","aug.inverse","(","out",")","tensor","(","[","[","[","[","0.3565",",","0.4839",",","0.1922","]",",","[","0.2164",",","0.4134",",","0.3968","]",",","[","0.3797",",","0.6075",",","0.3765","]","]","]","]",")","To","apply","the","exact","augmenation","again",",","you","may","take","the","advantage","of","the","previous","parameter","state",":",">",">",">","input","=","torch.randn","(","1",",","3",",","32",",","32",")",">",">",">","aug","=","RandomTranslate","(","(","-0.2",",","0.2",")",",","(","-0.1",",","0.1",")",",","p=1",".",")",">",">",">","(","aug","(","input",")","==","aug","(","input",",","params=aug._params",")",")",".all","(",")","tensor","(","True",")"]
code: def inverse_transform(
      self,
      input: Tensor,
      flags: Dict[str, Any],
      transform: Optional[Tensor] = None,
      size: Optional[Tuple[int, int]] = None,
  ) -> Tensor:
      if not isinstance(transform, Tensor):
          raise TypeError(
              f"Expected the `transform` be a Tensor. Got {type(transform)}."
          )
      return self.apply_transform(
          input,
          params=self._params,
          transform=as_tensor(
              transform, device=input.device, dtype=input.dtype
          ),
          flags=flags,
      )
  
file_path: kornia/kornia/augmentation/_2d/geometric/translate.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, stack
  from kornia.geometry.transform import get_translation_matrix2d, warp_affine
label_desc: Use image node_id 4 for calling the RandomTranslate obj's underlying member method code with example usage: obj.inverse_transform(input, flags, transform, size) and returns: self