code: def maybe_flip(image, label, flip_axis, flip_indicator=None):
      """Randomly flip the image."""
      if flip_indicator is None:
          flip_indicator = tf.random_uniform(shape=[])
      flip_or_not = tf.greater(flip_indicator, 0.5)
  
      def _maybe_flip(data):
          """Flip or not according to flip_or_not."""
          data = tf.cond(
              tf.logical_and(flip_or_not, tf.equal(flip_axis, 1)),
              lambda: tf.transpose(data, [1, 0, 2]),
              lambda: data,
          )
          data = tf.cond(
              tf.logical_and(flip_or_not, tf.equal(flip_axis, 2)),
              lambda: tf.transpose(data, [2, 1, 0]),
              lambda: data,
          )
  
          data = tf.cond(
              flip_or_not,
              lambda: tf.image.flip_up_down(data),
              lambda: data,
          )
  
          data = tf.cond(
              tf.logical_and(flip_or_not, tf.equal(flip_axis, 1)),
              lambda: tf.transpose(data, [1, 0, 2]),
              lambda: data,
          )
          data = tf.cond(
              tf.logical_and(flip_or_not, tf.equal(flip_axis, 2)),
              lambda: tf.transpose(data, [2, 1, 0]),
              lambda: data,
          )
          return data
  
      return _maybe_flip(image), _maybe_flip(label)
  
file_path: mesh/mesh_tensorflow/experimental/data_aug_lib.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow.compat.v1
  import tensorflow_probability
  from tensorflow.contrib import image
label_desc: Use image node_id 7 for calling a global function with example usage: maybe_flip(image, label, flip_axis, flip_indicator) and returns: _maybe_flip,  _maybe_flip, data