def _indexing(x, indices):
    """

    :param x: array from which indices has to be fetched
    :param indices: indices to be fetched
    :return: sub-array from given array and indices
    """
    # np array indexing
    if hasattr(x, 'shape'):
        return x[indices]
    
    # list indexing
    return [x[idx] for idx in indices]