def distort_image_with_autoaugment(image, bboxes, augmentation_name):
  """Applies the AutoAugment policy to `image` and `bboxes`.

  Args:
    image: `Tensor` of shape [height, width, 3] representing an image.
    bboxes: `Tensor` of shape [N, 4] representing ground truth boxes that are
      normalized between [0, 1].
    augmentation_name: The name of the AutoAugment policy to use. The available
      options are `v0`, `v1`, `v2`, `v3` and `test`. `v0` is the policy used for
      all of the results in the paper and was found to achieve the best results
      on the COCO dataset. `v1`, `v2` and `v3` are additional good policies
      found on the COCO dataset that have slight variation in what operations
      were used during the search procedure along with how many operations are
      applied in parallel to a single image (2 vs 3).

  Returns:
    A tuple containing the augmented versions of `image` and `bboxes`.
  """
  image = tf.cast(image, tf.uint8)
  available_policies = {'v0': policy_v0, 'v1': policy_v1, 'v2': policy_v2,
                        'v3': policy_v3, 'test': policy_vtest}
  if augmentation_name not in available_policies:
    raise ValueError('Invalid augmentation_name: {}'.format(augmentation_name))

  policy = available_policies[augmentation_name]()
  # Hparams that will be used for AutoAugment.
  augmentation_hparams = contrib_training.HParams(
      cutout_max_pad_fraction=0.75,
      cutout_bbox_replace_with_mean=False,
      cutout_const=100,
      translate_const=250,
      cutout_bbox_const=50,
      translate_bbox_const=120)

  augmented_image, augmented_bbox = (
      build_and_apply_nas_policy(policy, image, bboxes, augmentation_hparams))
  augmented_image = tf.cast(augmented_image, tf.float32)
  return augmented_image, augmented_bbox
Applies the AutoAugment policy to `image` and `bboxes`.

  Args:
    image: `Tensor` of shape [height, width, 3] representing an image.
    bboxes: `Tensor` of shape [N, 4] representing ground truth boxes that are
      normalized between [0, 1].
    augmentation_name: The name of the AutoAugment policy to use. The available
      options are `v0`, `v1`, `v2`, `v3` and `test`. `v0` is the policy used for
      all of the results in the paper and was found to achieve the best results
      on the COCO dataset. `v1`, `v2` and `v3` are additional good policies
      found on the COCO dataset that have slight variation in what operations
      were used during the search procedure along with how many operations are
      applied in parallel to a single image (2 vs 3).

  Returns:
    A tuple containing the augmented versions of `image` and `bboxes`.
  
inference_api/src/main/object_detection/utils/autoaugment_utils.py