def make_non_negative_axis(axis, rank):
axis = tf.convert_to_tensor(value=axis, name="<STR_LIT>")<EOL>rank = tf.convert_to_tensor(value=rank, name="<STR_LIT>")<EOL>axis_ = tf.get_static_value(axis)<EOL>rank_ = tf.get_static_value(rank)<EOL>if axis_ is not None and rank_ is not None:<EOL><INDENT>is_scalar = axis_.ndim == <NUM_LIT:0><EOL>if is_scalar:<EOL><INDENT>axis_ = [axis_]<EOL><DEDENT>positive_axis = []<EOL>for a_ in axis_:<EOL><INDENT>if a_ < <NUM_LIT:0>:<EOL><INDENT>positive_axis.append(rank_ + a_)<EOL><DEDENT>else:<EOL><INDENT>positive_axis.append(a_)<EOL><DEDENT><DEDENT>if is_scalar:<EOL><INDENT>positive_axis = positive_axis[<NUM_LIT:0>]<EOL><DEDENT>return tf.convert_to_tensor(value=positive_axis, dtype=axis.dtype)<EOL><DEDENT>return tf.where(axis < <NUM_LIT:0>, rank + axis, axis)<EOL>
Make (possibly negatively indexed) `axis` argument non-negative.