class_docstr: Add random elastic transformation to a tensor image.
  
  .. image:: _static/img/RandomElasticTransform.png
  
  Args:
      kernel_size: the size of the Gaussian kernel.
      sigma: The standard deviation of the Gaussian in the y and x directions,
        respectively. Larger sigma results in smaller pixel displacements.
      alpha: The scaling factor that controls the intensity of the deformation
        in the y and x directions, respectively.
      align_corners: Interpolation flag used by `grid_sample`.
      resample: Interpolation mode used by `grid_sample`. Either 'nearest' (0) or 'bilinear' (1).
      padding_mode: The padding used by ```grid_sample```. Either 'zeros', 'border' or 'refection'.
      same_on_batch: apply the same transformation across the batch.
      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).
  
  .. note::
      This function internally uses :func:`kornia.geometry.transform.elastic_transform2d`.
  
  Examples:
      >>> import torch
      >>> img = torch.ones(1, 1, 2, 2)
      >>> out = RandomElasticTransform()(img)
      >>> out.shape
      torch.Size([1, 1, 2, 2])
  
  To apply the exact augmenation again, you may take the advantage of the previous parameter state:
      >>> input = torch.randn(1, 3, 32, 32)
      >>> aug = RandomElasticTransform(p=1.)
      >>> (aug(input) == aug(input, params=aug._params)).all()
      tensor(True)
class_docstr_tok: ["Add","random","elastic","transformation","to","a","tensor","image",".","..","image",":",":","_static\/img\/RandomElasticTransform.png","Args",":","kernel_size",":","the","size","of","the","Gaussian","kernel",".","sigma",":","The","standard","deviation","of","the","Gaussian","in","the","y","and","x","directions",",","respectively",".","Larger","sigma","results","in","smaller","pixel","displacements",".","alpha",":","The","scaling","factor","that","controls","the","intensity","of","the","deformation","in","the","y","and","x","directions",",","respectively",".","align_corners",":","Interpolation","flag","used","by","`","grid_sample","`",".","resample",":","Interpolation","mode","used","by","`","grid_sample","`",".","Either","'nearest","'","(","0",")","or","'bilinear","'","(","1",")",".","padding_mode",":","The","padding","used","by","``","`","grid_sample","``","`",".","Either","'zeros","'",",","'border","'","or","'refection","'",".","same_on_batch",":","apply","the","same","transformation","across","the","batch",".","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",")",".","..","note",":",":","This","function","internally","uses",":","func",":","`","kornia.geometry.transform.elastic_transform2d","`",".","Examples",":",">",">",">","import","torch",">",">",">","img","=","torch.ones","(","1",",","1",",","2",",","2",")",">",">",">","out","=","RandomElasticTransform","(",")","(","img",")",">",">",">","out.shape","torch.Size","(","[","1",",","1",",","2",",","2","]",")","To","apply","the","exact","augmenation","again",",","you","may","take","the","advantage","of","the","previous","parameter","state",":",">",">",">","input","=","torch.randn","(","1",",","3",",","32",",","32",")",">",">",">","aug","=","RandomElasticTransform","(","p=1",".",")",">",">",">","(","aug","(","input",")","==","aug","(","input",",","params=aug._params",")",")",".all","(",")","tensor","(","True",")"]
code: def generate_parameters(
      self, shape: Tuple[int, ...]
  ) -> Dict[str, Tensor]:
      B, _, H, W = shape
      if self.same_on_batch:
          noise = torch.rand(
              1, 2, H, W, device=self.device, dtype=self.dtype
          ).expand(B, 2, H, W)
      else:
          noise = torch.rand(
              B, 2, H, W, device=self.device, dtype=self.dtype
          )
      return {"noise": noise * 2 - 1}
  
file_path: kornia/kornia/augmentation/_2d/geometric/elastic_transform.py
imports: from typing import Any, Dict, Optional, Tuple, Union
  import torch
  from kornia.augmentation._2d.base import AugmentationBase2D
  from kornia.constants import Resample
  from kornia.core import Tensor
  from kornia.geometry.boxes import Boxes
  from kornia.geometry.transform import elastic_transform2d
label_desc: Use image node_id 2 for calling the RandomElasticTransform obj's underlying member method code with example usage: obj.generate_parameters(shape) and returns: dict