class_docstr: Apply multiple elementary affine transforms simultaneously.
  
  Args:
      angle: Angle in degrees for counter-clockwise rotation around the center. The tensor
          must have a shape of (B), where B is the batch size.
      translation: Amount of pixels for translation in x- and y-direction. The tensor must
          have a shape of (B, 2), where B is the batch size and the last dimension contains dx and dy.
      scale_factor: Factor for scaling. The tensor must have a shape of (B), where B is the
          batch size.
      shear: Angles in degrees for shearing in x- and y-direction around the center. The
          tensor must have a shape of (B, 2), where B is the batch size and the last dimension contains sx and sy.
      center: Transformation center in pixels. The tensor must have a shape of (B, 2), where
          B is the batch size and the last dimension contains cx and cy. Defaults to the center of image to be
          transformed.
      mode: interpolation mode to calculate output values
        ``'bilinear'`` | ``'nearest'``.
      padding_mode: padding mode for outside grid values
        ``'zeros'`` | ``'border'`` | ``'reflection'``.
      align_corners: interpolation flag.
  
  Raises:
      RuntimeError: If not one of ``angle``, ``translation``, ``scale_factor``, or ``shear`` is set.
  
  Returns:
      The transformed tensor with same shape as input.
  
  Example:
      >>> img = torch.rand(1, 2, 3, 5)
      >>> angle = 90. * torch.rand(1)
      >>> out = Affine(angle)(img)
      >>> print(out.shape)
      torch.Size([1, 2, 3, 5])
class_docstr_tok: ["Apply","multiple","elementary","affine","transforms","simultaneously",".","Args",":","angle",":","Angle","in","degrees","for","counter-clockwise","rotation","around","the","center",".","The","tensor","must","have","a","shape","of","(","B",")",",","where","B","is","the","batch","size",".","translation",":","Amount","of","pixels","for","translation","in","x-","and","y-direction",".","The","tensor","must","have","a","shape","of","(","B",",","2",")",",","where","B","is","the","batch","size","and","the","last","dimension","contains","dx","and","dy",".","scale_factor",":","Factor","for","scaling",".","The","tensor","must","have","a","shape","of","(","B",")",",","where","B","is","the","batch","size",".","shear",":","Angles","in","degrees","for","shearing","in","x-","and","y-direction","around","the","center",".","The","tensor","must","have","a","shape","of","(","B",",","2",")",",","where","B","is","the","batch","size","and","the","last","dimension","contains","sx","and","sy",".","center",":","Transformation","center","in","pixels",".","The","tensor","must","have","a","shape","of","(","B",",","2",")",",","where","B","is","the","batch","size","and","the","last","dimension","contains","cx","and","cy",".","Defaults","to","the","center","of","image","to","be","transformed",".","mode",":","interpolation","mode","to","calculate","output","values","``","'bilinear","'","``","|","``","'nearest","'","``",".","padding_mode",":","padding","mode","for","outside","grid","values","``","'zeros","'","``","|","``","'border","'","``","|","``","'reflection","'","``",".","align_corners",":","interpolation","flag",".","Raises",":","RuntimeError",":","If","not","one","of","``","angle","``",",","``","translation","``",",","``","scale_factor","``",",","or","``","shear","``","is","set",".","Returns",":","The","transformed","tensor","with","same","shape","as","input",".","Example",":",">",">",">","img","=","torch.rand","(","1",",","2",",","3",",","5",")",">",">",">","angle","=","90",".","*","torch.rand","(","1",")",">",">",">","out","=","Affine","(","angle",")","(","img",")",">",">",">","print","(","out.shape",")","torch.Size","(","[","1",",","2",",","3",",","5","]",")"]
code: def __init__(
      self,
      angle: Optional[torch.Tensor] = None,
      translation: Optional[torch.Tensor] = None,
      scale_factor: Optional[torch.Tensor] = None,
      shear: Optional[torch.Tensor] = None,
      center: Optional[torch.Tensor] = None,
      mode: str = "bilinear",
      padding_mode: str = "zeros",
      align_corners: bool = True,
  ) -> None:
      batch_sizes = [
          arg.size()[0]
          for arg in (angle, translation, scale_factor, shear)
          if arg is not None
      ]
      if not batch_sizes:
          msg = (
              "Affine was created without any affine parameter. At least one of angle, translation, scale_factor, or "
              "shear has to be set."
          )
          raise RuntimeError(msg)
  
      batch_size = batch_sizes[0]
      if not all(other == batch_size for other in batch_sizes[1:]):
          raise RuntimeError(
              f"The batch sizes of the affine parameters mismatch: {batch_sizes}"
          )
  
      self._batch_size = batch_size
  
      super().__init__()
      device, dtype = _extract_device_dtype(
          [angle, translation, scale_factor]
      )
  
      if angle is None:
          angle = zeros(batch_size, device=device, dtype=dtype)
      self.angle = angle
  
      if translation is None:
          translation = zeros(batch_size, 2, device=device, dtype=dtype)
      self.translation = translation
  
      if scale_factor is None:
          scale_factor = ones(batch_size, 2, device=device, dtype=dtype)
      self.scale_factor = scale_factor
  
      self.shear = shear
      self.center = center
      self.mode = mode
      self.padding_mode = padding_mode
      self.align_corners = align_corners
  
imports: from typing import Optional, Tuple, Union
  import torch
  from torch import nn
  from kornia.core import ones, ones_like, zeros
  from kornia.filters import gaussian_blur2d
  from kornia.utils import _extract_device_dtype
  from kornia.utils.image import perform_keep_shape_image
  from kornia.utils.misc import eye_like
  from .imgwarp import get_affine_matrix2d, get_projective_transform, get_rotation_matrix2d, warp_affine, warp_affine3d
label_desc: Use image node_id 1 to create a new Affine object from inherited base classes: nn with example: obj = Affine(angle, translation, scale_factor, shear, center, mode, padding_mode, align_corners)