def E_logpZ( self, Data, LP):
        ''' This term is a bit complicated for the structured mean-field approach
        We have to calculate Z_ij, which we have in LP
        '''
        E_pi_i_sum = np.sum(LP['E_logsoftev_pi_i'], axis=1)
        E_pi_j_sum = np.sum(LP['E_logsoftev_pi_j'], axis=1)

        E_logpZ = ( LP['edge_variational'] \
                + np.exp( LP['E_logsoftev_pi_i'] + LP['E_logsoftev_EdgeEps'][:,np.newaxis] ) \
                * ( np.exp(E_pi_j_sum[:,np.newaxis]) - np.exp(LP['E_logsoftev_pi_j']) ) )\
                * LP['E_logsoftev_pi_i']
        E_logpZ += ( LP['edge_variational'] \
                + np.exp( LP['E_logsoftev_pi_j'] + LP['E_logsoftev_EdgeEps'][:,np.newaxis] ) \
                * ( np.exp(E_pi_i_sum[:,np.newaxis]) - np.exp(LP['E_logsoftev_pi_i']) ) )\
                * LP['E_logsoftev_pi_j']
        return np.sum(E_logpZ)
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/allocmodel/admix/HDPRelModel.py/HDPRelAssortModel.E_logpZ/original