def METHOD_NAME(param, n, nlayers, ps, cut, is_vmap=True):
    pst = tc.array_to_tensor(ps)
    res = 0.0
    mask1s = []
    mask2s = []
    for mask1 in product(*[(0, 1) for _ in cut]):
        mask1t = tc.array_to_tensor(np.array(mask1))
        mask1s.append(mask1t)
        mask2 = list(mask1)
        for j, i in enumerate(cut):
            if ps[i] in [1, 2]:
                mask2[j] = 1 - mask1[j]
        mask2t = tc.array_to_tensor(np.array(mask2))
        mask2s.append(mask2t)
    if is_vmap:
        mask1s = K.stack(mask1s)
        mask2s = K.stack(mask2s)
        res = sliced_core_vvg(param, n, nlayers, pst, cut, mask1s, mask2s)
        res = list(res)
        res[0] = K.sum(res[0])
        res = tuple(res)
    else:
        # memory bounded
        # can modified to adpative pmap
        vs = 0.0
        gs = 0.0
        for i in range(len(mask1s)):
            mask1t = mask1s[i]
            mask2t = mask2s[i]
            v, g = sliced_core_vg(param, n, nlayers, pst, cut, mask1t, mask2t)
            vs += v
            gs += g
        res = (vs, gs)
    return res