def METHOD_NAME(paramx, paramzz):
    if mpsd is None:
        c = tc.Circuit(n)
    else:
        c = tc.MPSCircuit(n)
        c.set_split_rules({"max_singular_values": mpsd})
    paramx = tc.backend.cast(paramx, dtype)
    paramzz = tc.backend.cast(paramzz, dtype)
    for i in range(n):
        c.H(i)
    for j in range(nlayer):
        for i in range(n - minus):
            c.exp1(
                i,
                (i + 1) % n,
                theta=paramzz[j * n + i],
                unitary=tc.gates._zz_matrix,
            )
        for i in range(n):
            c.rx(i, theta=paramx[j * n + i])
    if mpsd is None:
        e = tfi_energy(c, n)
        fd = 1.0
    else:
        e = tfi_energy(c, n)
        fd = c._fidelity
    # tensorflow only works for complex case, while jax only works for real case, don't know how to solve it
    # if tcbackend != "tensorflow":
    e = tc.backend.real(e)
    return e, fd