code: def create_grid(
      condition: ConditionalInfo,
      variable: Union[VariableInfo, None] = None,
      **kwargs,
  ) -> pd.DataFrame:
      """Creates a grid of data by using the covariates passed into the 'conditional'
      and  'variable' argument.
  
      Values for the grid are either:
          1.) computed using an equally spaced grid (`np.linspace`), mean, and or mode
              depending on the covariate dtype.
          2.) a user specified value or range of values if `condition.user_passed = True`
  
      Parameters
      ----------
      condition : ConditionalInfo
          Information about data passed to the conditional parameter of 'comparisons',
          'predictions', or 'slopes' related functions.
      variable : VariableInfo, optional
          Information about data passed to the variable of interest parameter. This
          is 'contrast' for 'comparisons', 'wrt' for 'slopes', and 'None' for 'predictions'.
      **kwargs : dict
          Optional keywords arguments such as 'effect_type' (the effect being computed),
          and 'num' (the number of values to return when computing a `np.linspace` grid).
  
      Returns
      -------
      pd.DataFrame
          A dataframe containing pairwise combinations of values.
      """
      model, observed_data = condition.model, condition.model.data
  
      if condition.user_passed:
          # shallow copy of user-passed data dictionary
          data_dict = {**condition.conditional}
      else:
          data_dict = {}
          # values here are the names of the covariates
          for covariate in condition.covariates.values():
              x = observed_data[covariate]
              num = kwargs.get("num", 50)
              if is_numeric_dtype(x) or is_float_dtype(x):
                  values = np.linspace(np.min(x), np.max(x), num)
              elif is_integer_dtype(x):
                  values = np.quantile(x, np.linspace(0, 1, 5))
              elif (
                  is_categorical_dtype(x)
                  or is_string_dtype(x)
                  or is_object_dtype(x)
              ):
                  values = np.unique(x)
              else:
                  raise TypeError(
                      f"Unsupported data type of {x.dtype} for covariate '{covariate.name}'"
                  )
  
              data_dict[covariate] = values
  
      if variable:
          data_dict[variable.name] = variable.values
  
      # set typical values as defaults for unspecified covariates
      data_dict = set_default_values(model, data_dict)
      data_grid = _pairwise_grid(data_dict)
  
      # can't enforce dtype on 'with respect to' variable for 'slopes' as it
      # may remove floating point in the epsilon
      effect = kwargs.get("effect_type", None)
      if effect == "slopes":
          except_col = variable.name
      else:
          except_col = None
  
      data_grid = enforce_dtypes(observed_data, data_grid, except_col)
  
      # after computing default values, fractional values may have been computed.
      # Enforcing the dtype of "int" may create duplicate rows as it will round
      # the fractional values.
      data_grid = data_grid.drop_duplicates()
  
      return data_grid.reset_index(drop=True)
  
file_path: bambi/bambi/interpret/create_data.py
imports: import itertools
  from typing import Union
  from statistics import mode
  import numpy
  import pandas
  from pandas.api.types import is_categorical_dtype, is_float_dtype, is_integer_dtype, is_numeric_dtype, is_object_dtype, is_string_dtype
  from bambi import Model
  from bambi.interpret.utils import ConditionalInfo, enforce_dtypes, get_model_covariates, VariableInfo
  from bambi.interpret.logs import log_interpret_defaults
label_desc: Use image node_id 1 for calling a global function with example usage: create_grid(condition, variable) and returns: data_grid