code: def maybe_rot180(image, label, static_axis, rot180_k=None):
      """Randomly rotate the image 180 degrees."""
      if rot180_k is None:
          rot180_k = 2 * tf.random_uniform(
              shape=[], minval=0, maxval=2, dtype=tf.int32
          )
      rot_or_not = tf.not_equal(rot180_k, 0)
  
      def _maybe_rot180(data):
          """Rotate or not according to rot_or_not."""
          data = tf.cond(
              tf.logical_and(rot_or_not, tf.equal(static_axis, 0)),
              lambda: tf.transpose(data, [2, 1, 0]),
              lambda: data,
          )
          data = tf.cond(
              tf.logical_and(rot_or_not, tf.equal(static_axis, 1)),
              lambda: tf.transpose(data, [0, 2, 1]),
              lambda: data,
          )
  
          data = tf.cond(
              rot_or_not,
              lambda: tf.image.rot90(data, k=rot180_k),
              lambda: data,
          )
  
          data = tf.cond(
              tf.logical_and(rot_or_not, tf.equal(static_axis, 0)),
              lambda: tf.transpose(data, [2, 1, 0]),
              lambda: data,
          )
          data = tf.cond(
              tf.logical_and(rot_or_not, tf.equal(static_axis, 1)),
              lambda: tf.transpose(data, [0, 2, 1]),
              lambda: data,
          )
          return data
  
      return _maybe_rot180(image), _maybe_rot180(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 8 for calling a global function with example usage: maybe_rot180(image, label, static_axis, rot180_k) and returns: _maybe_rot180,  _maybe_rot180, data