code: def _ensure_nonnegative_int(n):
      """Ensure n is a nonnegative integer."""
      n = op.index(n)
      if n < 0:
          raise nx.NetworkXError(
              f"Negative number of nodes not valid: {n}"
          )
      return n
  
file_path: cugraph/python/nx-cugraph/nx_cugraph/generators/_utils.py
imports: import operator
  import cupy
  import networkx
  import nx_cugraph
  from ..utils import index_dtype
label_desc: Use image node_id 2 for calling a global function with example usage: _ensure_nonnegative_int(n) and returns: n