code: def warp_image_tps(
      image: torch.Tensor,
      kernel_centers: torch.Tensor,
      kernel_weights: torch.Tensor,
      affine_weights: torch.Tensor,
      align_corners: bool = False,
  ) -> torch.Tensor:
      r"""Warp an image tensor according to the thin plate spline transform defined by kernel centers, kernel weights,
      and affine weights.
  
      .. image:: _static/img/warp_image_tps.png
  
      The transform is applied to each pixel coordinate in the output image to obtain a point in the input
      image for interpolation of the output pixel. So the TPS parameters should correspond to a warp from
      output space to input space.
  
      The input `image` is a :math:`(B, C, H, W)` tensor. The kernel centers, kernel weight and affine weights
      are the same as in `warp_points_tps`.
  
      Args:
          image: input image tensor :math:`(B, C, H, W)`.
          kernel_centers: kernel center points :math:`(B, K, 2)`.
          kernel_weights: tensor of kernl weights :math:`(B, K, 2)`.
          affine_weights: tensor of affine weights :math:`(B, 3, 2)`.
          align_corners: interpolation flag used by `grid_sample`.
  
      Returns:
          warped image tensor :math:`(B, C, H, W)`.
  
      Example:
          >>> points_src = torch.rand(1, 5, 2)
          >>> points_dst = torch.rand(1, 5, 2)
          >>> image = torch.rand(1, 3, 32, 32)
          >>> # note that we are getting the reverse transform: dst -> src
          >>> kernel_weights, affine_weights = get_tps_transform(points_dst, points_src)
          >>> warped_image = warp_image_tps(image, points_src, kernel_weights, affine_weights)
  
      .. note::
          This function is often used in conjunction with :func:`get_tps_transform`.
      """
      if not isinstance(image, torch.Tensor):
          raise TypeError(
              f"Input image is not torch.Tensor. Got {type(image)}"
          )
  
      if not isinstance(kernel_centers, torch.Tensor):
          raise TypeError(
              f"Input kernel_centers is not torch.Tensor. Got {type(kernel_centers)}"
          )
  
      if not isinstance(kernel_weights, torch.Tensor):
          raise TypeError(
              f"Input kernel_weights is not torch.Tensor. Got {type(kernel_weights)}"
          )
  
      if not isinstance(affine_weights, torch.Tensor):
          raise TypeError(
              f"Input affine_weights is not torch.Tensor. Got {type(affine_weights)}"
          )
  
      if not len(image.shape) == 4:
          raise ValueError(
              f"Invalid shape for image, expected BxCxHxW. Got {image.shape}"
          )
  
      if not len(kernel_centers.shape) == 3:
          raise ValueError(
              f"Invalid shape for kernel_centers, expected BxNx2. Got {kernel_centers.shape}"
          )
  
      if not len(kernel_weights.shape) == 3:
          raise ValueError(
              f"Invalid shape for kernel_weights, expected BxNx2. Got {kernel_weights.shape}"
          )
  
      if not len(affine_weights.shape) == 3:
          raise ValueError(
              f"Invalid shape for affine_weights, expected BxNx2. Got {affine_weights.shape}"
          )
  
      batch_size, _, h, w = image.shape
      coords: torch.Tensor = create_meshgrid(
          h, w, device=image.device, dtype=image.dtype
      )
      coords = coords.reshape(-1, 2).expand(batch_size, -1, -1)
      warped: torch.Tensor = warp_points_tps(
          coords, kernel_centers, kernel_weights, affine_weights
      )
      warped = warped.view(-1, h, w, 2)
      warped_image: torch.Tensor = nn.functional.grid_sample(
          image, warped, align_corners=align_corners
      )
  
      return warped_image
  
file_path: kornia/kornia/geometry/transform/thin_plate_spline.py
imports: from __future__ import annotations
  import torch
  from torch import nn
  from kornia.core import ones, zeros
  from kornia.utils import create_meshgrid
  from kornia.utils.helpers import _torch_solve_cast
label_desc: Use image node_id 5 for calling a global function with example usage: warp_image_tps(image, kernel_centers, kernel_weights, affine_weights, align_corners) and returns: warped_image