code: def _parse_index(indices, ndims):
      ind = []
      for so in indices:
          pre = []
          for s in so:
              if s == -1:
                  break
              pre.append(s.item())
          post = []
          for s in reversed(so):
              if s == -1:
                  break
              post.append(s.item())
          ind.append(
              tuple(
                  pre
                  + [
                      slice(None, None, None)
                      for _ in range(ndims - len(pre) - len(post))
                  ]
                  + list(reversed(post))
              )
          )
      return ind
  
imports: from functools import reduce
  from numbers import Number
  from operator import mul
  from typing import Optional, Union, Sequence, Callable, List, Tuple
  import numpy
  import torch
  import ivy
  from ivy.func_wrapper import with_unsupported_dtypes, _update_torch_views
  from .None import backend_version, is_variable
  from ...ivy.general import _broadcast_to
label_desc: Use image node_id 1 for calling a global function with example usage: _parse_index(indices, ndims) and returns: ind