code: def _compute_affine_transform_coordinates(image, transform):
      need_squeeze = False
      if len(image.shape) == 3:  # unbatched
          need_squeeze = True
          image = np.expand_dims(image, axis=0)
          transform = np.expand_dims(transform, axis=0)
      batch_size = image.shape[0]
      # get indices
      meshgrid = np.meshgrid(
          *[np.arange(size) for size in image.shape[1:]], indexing="ij"
      )
      indices = np.concatenate(
          [np.expand_dims(x, axis=-1) for x in meshgrid], axis=-1
      )
      indices = np.tile(indices, (batch_size, 1, 1, 1, 1))
      # swap the values
      transform[:, 4], transform[:, 0] = (
          transform[:, 0].copy(),
          transform[:, 4].copy(),
      )
      transform[:, 5], transform[:, 2] = (
          transform[:, 2].copy(),
          transform[:, 5].copy(),
      )
      # deal with transform
      transform = np.pad(
          transform, pad_width=[[0, 0], [0, 1]], constant_values=1
      )
      transform = np.reshape(transform, (batch_size, 3, 3))
      offset = np.pad(transform[:, 0:2, 2], pad_width=[[0, 0], [0, 1]])
      transform[:, 0:2, 2] = 0
      # transform the indices
      coordinates = np.einsum("Bhwij, Bjk -> Bhwik", indices, transform)
      coordinates = np.moveaxis(coordinates, source=-1, destination=1)
      coordinates += np.reshape(
          a=offset, newshape=(*offset.shape, 1, 1, 1)
      )
      if need_squeeze:
          coordinates = np.squeeze(coordinates, axis=0)
      return coordinates
  
imports: import math
  import numpy
  import pytest
  import scipy.ndimage
  import tensorflow
  from absl.testing import parameterized
  from keras import backend
  from keras import testing
  from keras.backend.common.keras_tensor import KerasTensor
  from keras.ops import image
label_desc: Use image node_id 1 for calling a global function with example usage: _compute_affine_transform_coordinates(image, transform) and returns: coordinates