def sample_Z(self):
    beta_matrix = np.reshape(self.current_beta, (self.J, self.K), order='F')
    f_matrix = np.reshape(self.current_f, (self.B, self.K), order='F')
    Z = self.current_Z
    f_full_matrix = gp_inflate_duplicate(f_matrix, self.block_assignment_numeric, self.N, self.K)
    counts = self.context.counts
    covariates = self.context.covariates
    fixed_effects_all = np.dot(covariates, beta_matrix)
    counts_matrix = np.repeat(counts.reshape(((- 1), 1)), self.K, axis=1)
    poi_lik = ((counts_matrix * fixed_effects_all) - np.exp(fixed_effects_all))
    gp_log_softmax = (f_full_matrix - logsumexp(f_full_matrix, axis=1)[:, np.newaxis])
    prob = softmax((poi_lik + gp_log_softmax), axis=1)
    new_Z = zsampler.sample_bulk_categorical(Z.astype(np.int64), prob.astype(np.float64))
    return new_Z
def sample_Z(self):
    beta_matrix = np.reshape(self.current_beta, (self.J, self.K), order='F')
    f_matrix = np.reshape(self.current_f, (self.B, self.K), order='F')
    Z = self.current_Z
    f_full_matrix = gp_inflate_duplicate(f_matrix, self.block_assignment_numeric, self.N, self.K)
    counts = self.context.counts
    covariates = self.context.covariates
    fixed_effects_all = np.dot(covariates, beta_matrix)
    counts_matrix = np.repeat(counts.reshape(((- 1), 1)), self.K, axis=1)
    poi_lik = ((counts_matrix * fixed_effects_all) - np.exp(fixed_effects_all))
    gp_log_softmax = (f_full_matrix - logsumexp(f_full_matrix, axis=1)[:, np.newaxis])
    prob = softmax((poi_lik + gp_log_softmax), axis=1)
    new_Z = zsampler.sample_bulk_categorical(Z.astype(np.int64), prob.astype(np.float64))
    return new_Z