<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sample_tmatrix(C, nsample=1, nsteps=None, reversible=False, mu=None, T0=None, return_statdist=False):
 r"""samples transition matrices from the posterior distribution Parameters C : (M, M) ndarray or scipy.sparse matrix Count matrix nsample : int number of samples to be drawn nstep : int, default=None number of full Gibbs sampling sweeps internally done for each sample returned. This option is meant to ensure approximately uncorrelated samples for every call to sample(). If None, the number of steps will be automatically determined based on the other options and the matrix size. nstep>1 will only be used for reversible sampling, because nonreversible sampling generates statistically independent transition matrices every step. reversible : bool If true sample from the ensemble of transition matrices restricted to those obeying a detailed balance condition, else draw from the whole ensemble of stochastic matrices. mu : array_like A fixed stationary distribution. Transition matrices with that stationary distribution will be sampled T0 : ndarray, shape=(n, n) or scipy.sparse matrix Starting point of the MC chain of the sampling algorithm. Has to obey the required constraints. return_statdist : bool, optional, default = False if true, will also return the stationary distribution. Returns ------- P : ndarray(n,n) or array of ndarray(n,n) sampled transition matrix (or multiple matrices if nsample > 1) Notes ----- The transition matrix sampler generates transition matrices from the posterior distribution. The posterior distribution is given as a product of Dirichlet distributions .. math:: \mathbb{P}(T|C) \propto \prod_{i=1}^{M} \left( \prod_{j=1}^{M} p_{ij}^{c_{ij}} \right) See also -------- tmatrix_sampler """

    if issparse(C):
        _showSparseConversionWarning()
        C = C.toarray()

    sampler = tmatrix_sampler(C, reversible=reversible, mu=mu, T0=T0, nsteps=nsteps)
    return sampler.sample(nsamples=nsample, return_statdist=return_statdist)