def _convert_index(index, pos, M=None, is_start=True):
  """Converts index."""
  if index[pos] is not None:
    return index[pos]
  N = len(index)