code: def generate_test_data_for_fitting(
      n=1000, seed=41, heteroscedastic=False
  ):
      """Generate data for testing the fitting algorithm with different parameters
          e.g. linear and random forest.
      :param n: integer
          sample size for both the generated training data (df) and the test data
          (df_test)
      :param seed: integer
          random number generator seed
      :param heteroscedastic: bool
          if True, response has heteroscedastic error
      :return: dict
          "df": pd.DataFrame
              the dataframe of generated input data for training of size n
          "df_test": pd.DataFrame
              the test dataframe of the same size (n)
          "y_test": pd.Series
              the response values for the test set
          "model_formula_str": str
              the model formula string
      """
      m = 2 * n
      np.random.seed(seed)
      x1 = np.random.normal(size=m)
      x2 = np.random.normal(size=m)
      x2 = np.sort(x2)
      x3 = np.random.normal(size=m)
      x4 = np.random.normal(size=m)
      err = np.random.normal(size=m)
      y = 10 + 2 * x2 + 8 * x4 + 2 * err
  
      df0 = pd.DataFrame(
          {"y": y, "x1": x1, "x2": x2, "x3": x3, "x4": x4}
      )
  
      if heteroscedastic:
          err_hetero = np.random.normal(size=m)
          df0["y"] = y + 5 * abs(x1) * err_hetero
  
      # define a categorical variable based on x1 values
      # this is useful for testing models which use categorical features
      df0["x1_categ"] = "C" + (2.0 * df0["x1"]).abs().round().map(
          int
      ).astype(str)
  
      df = df0[1:n]
      df_test = df0[n : (2 * n)]
      y_test = df_test["y"].copy()
  
      model_formula_str = (
          "y~x1+x2+x3+x4"  # note: x1_categ is not included by default
      )
  
      return {
          "df": df,
          "df_test": df_test,
          "y_test": y_test,
          "model_formula_str": model_formula_str,
      }
  
imports: import warnings
  import numpy
  import pandas
  import pytest
  import scipy
  from pandas.testing import assert_frame_equal
  from patsy import dmatrices
  from greykite.algo.common.ml_models import breakdown_regression_based_prediction
  from greykite.algo.common.ml_models import design_mat_from_formula
  from greykite.algo.common.ml_models import fit_ml_model
  from greykite.algo.common.ml_models import fit_ml_model_with_evaluation
  from greykite.algo.common.ml_models import fit_model_via_design_matrix
  from greykite.algo.common.ml_models import get_h_mat
  from greykite.algo.common.ml_models import get_intercept_col_from_design_mat
  from greykite.algo.common.ml_models import predict_ml
  from greykite.algo.common.ml_models import predict_ml_with_uncertainty
  from greykite.algo.uncertainty.conditional.conf_interval import predict_ci
  from greykite.common.constants import ERR_STD_COL
  from greykite.common.constants import QUANTILE_SUMMARY_COL
  from greykite.common.constants import TimeFeaturesEnum
  from greykite.common.evaluation import EvaluationMetricEnum
  from greykite.common.evaluation import calc_pred_err
  from greykite.common.features.timeseries_features import build_time_features_df
  from greykite.common.features.timeseries_features import fourier_series_multi_fcn
  from greykite.common.features.timeseries_features import get_fourier_col_name
  from greykite.common.python_utils import assert_equal
  from greykite.common.testing_utils import gen_sliced_df
label_desc: Use image node_id 14 for calling a global function with example usage: generate_test_data_for_fitting(n, seed, heteroscedastic) and returns: dict