code: def F_batch_affine2d(x, matrix, center=True):
      """
  
      x : torch.Tensor
          shape = (Samples, C, H, W)
          NOTE: Assume C is always equal to 1!
      matrix : torch.Tensor
          shape = (Samples, 6) or (Samples, 2, 3)
  
      Example
      -------
      >>> x = torch.zeros(3,1,10,10)
      >>> x[:,:,3:7,3:7] = 1
      >>> m1 = torch.FloatTensor([[1.2,0,0],[0,1.2,0]])
      >>> m2 = torch.FloatTensor([[0.8,0,0],[0,0.8,0]])
      >>> m3 = torch.FloatTensor([[1.0,0,3],[0,1.0,3]])
      >>> matrix = torch.stack([m1,m2,m3])
      >>> xx = F_batch_affine2d(x,matrix)
      """
      if matrix.dim() == 2:
          matrix = matrix.view(-1, 2, 3)
  
      A_batch = matrix[:, :, :2]
      b_batch = matrix[:, :, 2].unsqueeze(1)
  
      # make a meshgrid of normal coordinates
      _coords = th_iterproduct(x.size(2), x.size(3))
      with torch.no_grad:
          coords = _coords.unsqueeze(0).repeat(x.size(0), 1, 1).float()
  
      if center:
          # shift the coordinates so center is the origin
          coords[:, :, 0] = coords[:, :, 0] - (x.size(2) / 2.0 + 0.5)
          coords[:, :, 1] = coords[:, :, 1] - (x.size(3) / 2.0 + 0.5)
  
      # apply the coordinate transformation
      new_coords = coords.bmm(
          A_batch.transpose(1, 2)
      ) + b_batch.expand_as(coords)
  
      if center:
          # shift the coordinates back so origin is origin
          new_coords[:, :, 0] = new_coords[:, :, 0] + (
              x.size(2) / 2.0 + 0.5
          )
          new_coords[:, :, 1] = new_coords[:, :, 1] + (
              x.size(3) / 2.0 + 0.5
          )
  
      # map new coordinates using bilinear interpolation
      x_transformed = F_batch_bilinear_interp2d(x, new_coords)
  
      return x_transformed
  
file_path: pywick/pywick/functions/affine.py
imports: import torch
  import torch.nn.functional
  from ..utils import th_iterproduct, th_flatten
label_desc: Use image node_id 3 for calling a global function with example usage: F_batch_affine2d(x, matrix, center) and returns: x_transformed