code: def non_negative_axis(
      axis, rank, name=None
  ):  # pylint:disable=redefined-outer-name
      """Make (possibly negatively indexed) `axis` argument non-negative."""
      with tf.name_scope(name or "non_negative_axis"):
          if axis is None:
              return None
          if rank is None:
              raise ValueError("Argument `rank` cannot be `None`.")
          dtype = dtype_util.as_numpy_dtype(
              dtype_util.common_dtype([axis, rank], dtype_hint=tf.int32)
          )
          rank_ = tf.get_static_value(rank)
          axis_ = tf.get_static_value(axis)
          if rank_ is None or axis_ is None:
              axis = tf.convert_to_tensor(
                  axis, dtype=dtype, name="axis"
              )
              rank = tf.convert_to_tensor(
                  rank, dtype=dtype, name="rank"
              )
              return tf.where(axis < 0, rank + axis, axis)
          axis_ = np.array(axis_, dtype=dtype)
          rank_ = np.array(rank_, dtype=dtype)
          return np.where(axis_ < 0, axis_ + rank_, axis_)
  
imports: import decorator
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal.backend import numpy
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import control_flow_case
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 24 for calling a global function with example usage: non_negative_axis(axis, rank, name) and returns: np, None, tf