code: def posify_index(shape, ind):
      """Flip negative indices around to positive ones
  
      >>> posify_index(10, 3)
      3
      >>> posify_index(10, -3)
      7
      >>> posify_index(10, [3, -3])
      array([3, 7])
  
      >>> posify_index((10, 20), (3, -3))
      (3, 17)
      >>> posify_index((10, 20), (3, [3, 4, -3]))  # doctest: +NORMALIZE_WHITESPACE
      (3, array([ 3,  4, 17]))
      """
      if isinstance(ind, tuple):
          return tuple(map(posify_index, shape, ind))
      if isinstance(ind, Integral):
          if ind < 0 and not math.isnan(shape):
              return ind + shape
          else:
              return ind
      if isinstance(ind, (np.ndarray, list)) and not math.isnan(shape):
          ind = np.asanyarray(ind)
          return np.where(ind < 0, ind + shape, ind)
      return ind
  
imports: from __future__ import annotations
  import bisect
  import functools
  import math
  import warnings
  from itertools import product
  from numbers import Integral, Number
  from operator import itemgetter
  import numpy
  from tlz import concat, memoize, merge, pluck
  from dask import config, core, utils
  from dask.array.chunk import getitem
  from dask.base import is_dask_collection, tokenize
  from dask.highlevelgraph import HighLevelGraph
  from dask.utils import cached_cumsum, is_arraylike
label_desc: Use image node_id 12 for calling a global function with example usage: posify_index(shape, ind) and returns: ind, tuple, np, unknown, ind