class_docstr: PyMC model-fitting backend.
class_docstr_tok: ["PyMC","model-fitting","backend","."]
code: def _clean_results(self, idata, omit_offsets, include_mean):
      for group in idata.groups():
          getattr(idata, group).attrs["modeling_interface"] = "bambi"
          getattr(idata, group).attrs[
              "modeling_interface_version"
          ] = __version__
  
      if omit_offsets:
          offset_vars = [
              var
              for var in idata.posterior.data_vars
              if var.endswith("_offset")
          ]
          idata.posterior = idata.posterior.drop_vars(offset_vars)
  
      # Drop variables and dimensions associated with LKJ prior
      vars_to_drop = [
          var
          for var in idata.posterior.data_vars
          if var.startswith("_LKJ")
      ]
      dims_to_drop = [
          dim for dim in idata.posterior.dims if dim.startswith("_LKJ")
      ]
  
      idata.posterior = idata.posterior.drop_vars(vars_to_drop)
      idata.posterior = idata.posterior.drop_dims(dims_to_drop)
  
      dims_original = list(self.model.coords)
  
      # Discard dims that are in the model but unused in the posterior
      dims_original = [
          dim for dim in dims_original if dim in idata.posterior.dims
      ]
  
      # This does not add any new coordinate, it just changes the order so the ones
      # ending in "__factor_dim" are placed after the others.
      dims_group = [
          c for c in dims_original if c.endswith("__factor_dim")
      ]
  
      # Keep the original order in dims_original
      dims_original_set = set(dims_original) - set(dims_group)
      dims_original = [
          c for c in dims_original if c in dims_original_set
      ]
      dims_new = ["chain", "draw"] + dims_original + dims_group
      idata.posterior = idata.posterior.transpose(*dims_new)
  
      # Compute the actual intercept in all distributional components that have an intercept
  
      for pymc_component in self.distributional_components.values():
          bambi_component = pymc_component.component
          if (
              bambi_component.intercept_term
              and bambi_component.common_terms
              and self.spec.center_predictors
          ):
              chain_n = len(idata.posterior["chain"])
              draw_n = len(idata.posterior["draw"])
              shape, dims = (chain_n, draw_n), ("chain", "draw")
              X = pymc_component.design_matrix_without_intercept
  
              common_terms = []
              for term in bambi_component.common_terms.values():
                  common_terms.append(get_aliased_name(term))
  
              response_coords = (
                  self.spec.response_component.response_term.coords
              )
              if response_coords:
                  # Grab the first object in a dictionary
                  levels = list(response_coords.values())[0]
                  shape += (len(levels),)
                  dims += tuple(response_coords)
  
              posterior = idata.posterior.stack(samples=dims)
              coefs = np.vstack(
                  [
                      np.atleast_2d(posterior[name].values)
                      for name in common_terms
                  ]
              )
              name = get_aliased_name(bambi_component.intercept_term)
              center_factor = np.dot(X.mean(0), coefs).reshape(shape)
              idata.posterior[name] = (
                  idata.posterior[name] - center_factor
              )
  
      if include_mean:
          self.spec.predict(idata)
  
      return idata
  
imports: import functools
  import logging
  import traceback
  from copy import deepcopy
  from importlib.metadata import version
  import numpy
  import pymc
  import pytensor.tensor
  from pytensor.tensor.special import softmax
  from bambi.backend.links import cloglog, identity, inverse_squared, logit, probit, arctan_2
  from bambi.backend.model_components import ConstantComponent, DistributionalComponent
  from bambi.utils import get_aliased_name
label_desc: Use image node_id 7 for calling the PyMCModel obj's underlying member method code with example usage: obj._clean_results(idata, omit_offsets, include_mean) and returns: idata