<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _to_free_energy(z, minener_zero=False):
 """Compute free energies from histogram counts. Parameters z : ndarray(T) Histogram counts. minener_zero : boolean, optional, default=False Shifts the energy minimum to zero. Returns ------- free_energy : ndarray(T) The free energy values in units of kT. """

    pi = _to_density(z)
    free_energy = _np.inf * _np.ones(shape=z.shape)
    nonzero = pi.nonzero()
    free_energy[nonzero] = -_np.log(pi[nonzero])
    if minener_zero:
        free_energy[nonzero] -= _np.min(free_energy[nonzero])
    return free_energy