def stencil_converter(stencil: list, ndims: int) -> list:
    """
    Takes in the flattend stencil list and returns it
    in forms of tuples
    :param stencil: flattend list of rel. coord. Ex: [0, 1, 0, 2], ndims = 2
    :return: list with tuples. Ex: [(0, 1), (0, 2)]
    """
    converted_stencil = []
    for i in range(0, len(stencil), ndims):
        new_tuple = []
        for d in range(ndims):
            new_tuple.append(stencil[i + d])
        converted_stencil.append(tuple(new_tuple))
    return converted_stencil