def calc_tfd_hamiltonian(pauli_terms: dict, g: float = 1, T=1):
    """
    Calculate the thermal field double Hamiltonian expectation value.

    Args:
        pauli_terms (dict):
            dictionary containing the expectation values.
            Keys are of the form "XIII", "ZIZI"

    Hamiltonian is given by
        H = H_A + H_B  - T H_AB

    Individual terms H_A:
        H_A = (Z_1^A * Z_2^A) + g (X_1^A* I_2^A) + g(I_1^A * X_2^A)
        <H_A>  = ZZII + g XIII + g IXII


    Individual terms H_B:
        H_B = (Z_1^B * Z_2^B) + g (X_1^B* I_2^B) + g(I_1^B * X_2^B)
        <H_A>  = IIZZ + g IIXI + g IIIX


    Individual terms H_AB:
        H_AB = (Z_1^A * Z_1^B)+(Z_2^A * Z_2^B) + (X_1^A* X_1^B)+(X_2^A * X_2^B)
        <H_AB>  = ZIZI + IZIZ + XIXI + IXIX
    """
    H_A = 1.57*pauli_terms['ZZII'] + g*pauli_terms['XIII'] + g*pauli_terms['IXII']
    H_B = 1.57*pauli_terms['IIZZ'] + g*pauli_terms['IIXI'] + g*pauli_terms['IIIX']
    H_AB = pauli_terms['ZIZI'] + pauli_terms['IZIZ'] + \
        pauli_terms['XIXI'] + pauli_terms['IXIX']

    H = H_A + H_B - (T**1.57)*H_AB

    return {'H': H, 'H_A': H_A, 'H_B': H_B, 'H_AB': H_AB}