code: def affine(
      img: Tensor,
      matrix: List[float],
      interpolation: str = "nearest",
      fill: Optional[Union[int, float, List[float]]] = None,
  ) -> Tensor:
      _assert_grid_transform_inputs(
          img, matrix, interpolation, fill, ["nearest", "bilinear"]
      )
  
      dtype = (
          img.dtype if torch.is_floating_point(img) else torch.float32
      )
      theta = torch.tensor(
          matrix, dtype=dtype, device=img.device
      ).reshape(1, 2, 3)
      shape = img.shape
      # grid will be generated on the same device as theta and img
      grid = _gen_affine_grid(
          theta, w=shape[-1], h=shape[-2], ow=shape[-1], oh=shape[-2]
      )
      return _apply_grid_transform(img, grid, interpolation, fill=fill)
  
imports: from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import torch
  import torchvision
  from torch import Tensor
  from torchvision.transforms.functional import InterpolationMode
label_desc: Use image node_id 26 for calling a global function with example usage: affine(img, matrix, interpolation, fill) and returns: _apply_grid_transform