code: def _check_axis(axis, rank):
      if axis < 0:
          axis += rank
      if axis < 0 or axis >= rank:
          raise ValueError("invalid axis")
      return axis
  
imports: from __future__ import division, print_function, absolute_import
  import numpy
  from scipy._lib.six import string_types
label_desc: Use image node_id 4 for calling a global function with example usage: _check_axis(axis, rank) and returns: axis