code: def _prepare_idata(
      idata: InferenceData, data: xr.Dataset
  ) -> InferenceData:
      """Prepare InferenceData object for use in `select_draws` by removing the
      'observed_data' group and replacing it with another 'data' group that contains
      the data used to generate predictions.
  
      Parameters
      ----------
      idata : InferenceData
          InferenceData object containing the inference data after performing `model.predict`.
      data : xr.Dataset
          The Dataset passed as 'data' to `model.predict` to generate predictions.
  
      Returns
      -------
      InferenceData
          A new InferenceData object with the 'observed_data' group removed and
          replaced with a 'data' group that contains the 'data' used to generate
          predictions.
  
      Raises
      ------
      ValueError
          If the InferenceData object does not contain a 'data' or 'observed_data' group.
      """
  
      if "observed_data" in idata.groups():
          coordinate_name = list(idata["observed_data"].coords)
          del idata.observed_data
          idata.add_groups(data=data)
      else:
          raise ValueError(
              "InferenceData object does not contain a 'data' or 'observed_data' group."
          )
  
      if len(coordinate_name) > 1:
          raise NotImplementedError(
              "Only one coordinate is currently supported."
          )
      coordinate_name = coordinate_name[0]
  
      # rename index to match coordinate name in other InferenceData groups
      idata.data = idata.data.rename({"index": coordinate_name})
  
      return idata
  
file_path: bambi/bambi/interpret/helpers.py
imports: from typing import Union
  import warnings
  import numpy
  import pandas
  import xarray
  from arviz import InferenceData
  from bambi import Model
  from bambi.interpret.create_data import create_grid
  from bambi.interpret.utils import ConditionalInfo, VariableInfo
label_desc: Use image node_id 2 for calling a global function with example usage: _prepare_idata(idata, data) and returns: idata