Apply image transformations in parallel.
  :param transforms: TODO
  :param black_border_size: int, size of black border to apply
  Returns:
    Transformed images

def parallel_apply_transformations(x, transforms, black_border_size=0):
  """
  Apply image transformations in parallel.
  :param transforms: TODO
  :param black_border_size: int, size of black border to apply
  Returns:
    Transformed images
  """
  transforms = tf.convert_to_tensor(transforms, dtype=tf.float32)
  x = _apply_black_border(x, black_border_size)

  num_transforms = transforms.get_shape().as_list()[0]
  im_shape = x.get_shape().as_list()[1:]

  # Pass a copy of x and a transformation to each iteration of the map_fn
  # callable
  tiled_x = tf.reshape(
      tf.tile(x, [num_transforms, 1, 1, 1]),
      [num_transforms, -1] + im_shape)
  elems = [tiled_x, transforms]
  transformed_ims = tf.map_fn(
      _apply_transformation,
      elems,
      dtype=tf.float32,
      parallel_iterations=1,  # Must be 1 to avoid keras race conditions
  )
  return transformed_ims