code: def merge(
      y_hat_mean: xr.DataArray,
      y_hat_bounds: xr.DataArray,
      data: pd.DataFrame,
  ) -> pd.DataFrame:
      """
      Convert predictions ('y_hat_mean' and 'y_hat_bounds') into dataframes and join
      with the original data used to perform predictions. This will "duplicate" the
      data to ensure that the original data is aligned with each response dimension
      (level).
      """
  
      idx_names = y_hat_mean.to_dataframe().index.names
  
      yhat_df = (
          y_hat_mean.to_dataframe().reset_index().set_index(idx_names)
      )
      lower_df = (
          y_hat_bounds.sel(hdi="lower")
          .to_dataframe()
          .reset_index()
          .set_index(idx_names)
      )
      higher_df = (
          y_hat_bounds.sel(hdi="higher")
          .to_dataframe()
          .reset_index()
          .set_index(idx_names)
      )
      bounds_df = pd.merge(
          left=lower_df,
          right=higher_df,
          left_index=True,
          right_index=True,
      )
      preds_df = (
          pd.merge(
              left=yhat_df,
              right=bounds_df,
              left_index=True,
              right_index=True,
          )
          .reset_index()
          .set_index(idx_names[0])
      )
  
      summary_df = pd.merge(
          left=data, right=preds_df, left_index=True, right_index=True
      )
  
      return summary_df.drop(columns=["hdi_x", "hdi_y"])
  
imports: from dataclasses import dataclass, field
  from typing import Union
  import numpy
  from formulae.terms.call import Call
  import pandas
  import xarray
  from bambi import Model
  from bambi.utils import listify
  from bambi.interpret.logs import log_interpret_defaults
label_desc: Use image node_id 8 for calling a global function with example usage: merge(y_hat_mean, y_hat_bounds, data) and returns: summary_df