code: def flip_image(image, bboxes=None, left_right=True, up_down=False):
      """Flips image on its axis for data augmentation.
  
      Args:
          image: Tensor with image of shape (H, W, 3).
          bboxes: Optional Tensor with bounding boxes with shape
              (total_bboxes, 5).
          left_right: Boolean flag to flip the image horizontally
              (left to right).
          up_down: Boolean flag to flip the image vertically (upside down)
      Returns:
          image: Flipped image with the same shape.
          bboxes: Tensor with the same shape.
      """
      image_shape = tf.shape(image)
      height = image_shape[0]
      width = image_shape[1]
  
      if bboxes is not None:
          # bboxes usually come from dataset as ints, but just in case we are
          # using flip for preprocessing, where bboxes usually are represented as
          # floats, we cast them.
          bboxes = tf.to_int32(bboxes)
  
      if left_right:
          image = tf.image.flip_left_right(image)
          if bboxes is not None:
              x_min, y_min, x_max, y_max, label = tf.unstack(
                  bboxes, axis=1
              )
              new_x_min = width - x_max - 1
              new_y_min = y_min
              new_x_max = new_x_min + (x_max - x_min)
              new_y_max = y_max
              bboxes = tf.stack(
                  [new_x_min, new_y_min, new_x_max, new_y_max, label],
                  axis=1,
              )
  
      if up_down:
          image = tf.image.flip_up_down(image)
          if bboxes is not None:
              x_min, y_min, x_max, y_max, label = tf.unstack(
                  bboxes, axis=1
              )
              new_x_min = x_min
              new_y_min = height - y_max - 1
              new_x_max = x_max
              new_y_max = new_y_min + (y_max - y_min)
              bboxes = tf.stack(
                  [new_x_min, new_y_min, new_x_max, new_y_max, label],
                  axis=1,
              )
  
      return_dict = {"image": image}
      if bboxes is not None:
          return_dict["bboxes"] = bboxes
  
      return return_dict
  
file_path: luminoth/luminoth/utils/image.py
imports: import tensorflow
  from luminoth.utils.bbox_transform_tf import clip_boxes
label_desc: Use image node_id 5 for calling a global function with example usage: flip_image(image, bboxes, left_right, up_down) and returns: return_dict