def METHOD_NAME(c, cut, mask):
    # mask = Tensor([0, 1, 0])
    # cut = [0, 1, 2]
    n = c._nqubits
    ncut = len(cut)
    end0 = tc.array_to_tensor(np.array([1.0, 0.0]))
    end1 = tc.array_to_tensor(np.array([0.0, 1.0]))
    ends = [tc.Gate(mask[i] * end1 + (1 - mask[i]) * end0) for i in range(ncut)]
    nodes, front = c._copy()
    for j, i in enumerate(cut):
        front[i] ^ ends[j][0]
    oeo = []
    for i in range(n):
        if i not in cut:
            oeo.append(front[i])
    ss = tc.contractor(nodes + ends, output_edge_order=oeo)
    return ss