<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_emcee(sampler=None, *, var_names=None, arg_names=None, coords=None, dims=None):
 """Convert emcee data into an InferenceData object. Parameters sampler : emcee.EnsembleSampler Fitted sampler from emcee. var_names : list[str] (Optional) A list of names for variables in the sampler arg_names : list[str] (Optional) A list of names for args in the sampler coords : dict[str] -> list[str] Map of dimensions to coordinates dims : dict[str] -> list[str] Map variable names to their coordinates Returns ------- InferenceData Examples -------- Passing an ``emcee.EnsembleSampler`` object to ``az.from_emcee`` converts it to an InferenceData object. Start defining the model and running the sampler: .. plot:: :context: close-figs And convert the sampler to an InferenceData object. As emcee does not store variable names, they must be passed to the converter in order to have them: .. plot:: :context: close-figs From an InferenceData object, ArviZ's native data structure, the posterior plot of the first 3 variables can be done in one line: .. plot:: :context: close-figs And the trace: .. plot:: :context: close-figs Emcee is an Affine Invariant MCMC Ensemble Sampler, thus, its chains are **not** independent, which means that many ArviZ functions can not be used, at least directly. However, it is possible to combine emcee and ArviZ and use most of ArviZ functionalities. The first step is to modify the probability function to use the ``blobs`` and store the log_likelihood, then rerun the sampler using the new function: .. plot:: :context: close-figs ArviZ has no support for the ``blobs`` functionality yet, but a workaround can be created. First make sure that the dimensions are in the order ``(chain, draw, *shape)``. It may also be a good idea to apply a burn-in period and to thin the draw dimension (which due to the correlations between chains and consecutive draws, won't reduce the effective sample size if the value is small enough). Then convert the numpy arrays to InferenceData, in this case using ``az.from_dict``: .. plot:: :context: close-figs To calculate the effective sample size emcee's functions must be used. There are many changes in emcee's API from version 2 to 3, thus, the calculation is different depending on the version. In addition, in version 2, the autocorrelation time raises an error if the chain is not long enough. .. plot:: :context: close-figs This value can afterwards be used to estimate the leave-one-out cross-validation using Pareto smoothed importance sampling with ArviZ and plot the results: .. plot:: :context: close-figs """

    return EmceeConverter(
        sampler=sampler, var_names=var_names, arg_names=arg_names, coords=coords, dims=dims
    ).to_inference_data()