code: def create_pipeline(X, task_type):
      pipe_cfg = {
          "num_cols": X.dtypes[
              X.dtypes == "int64"
          ].index.values.tolist(),
          "cat_cols": X.dtypes[
              X.dtypes == "object"
          ].index.values.tolist(),
      }
      num_pipe = Pipeline(
          [
              ("num_imputer", SimpleImputer(strategy="median")),
              ("num_scaler", StandardScaler()),
          ]
      )
      cat_pipe = Pipeline(
          [
              (
                  "cat_imputer",
                  SimpleImputer(strategy="constant", fill_value="?"),
              ),
              (
                  "cat_encoder",
                  OneHotEncoder(handle_unknown="ignore", sparse=False),
              ),
          ]
      )
      feat_pipe = ColumnTransformer(
          [
              ("num_pipe", num_pipe, pipe_cfg["num_cols"]),
              ("cat_pipe", cat_pipe, pipe_cfg["cat_cols"]),
          ]
      )
  
      if task_type == "classification":
          pipeline = Pipeline(
              steps=[
                  ("preprocessor", feat_pipe),
                  (
                      "model",
                      RandomForestClassifier(
                          n_estimators=10, max_depth=5
                      ),
                  ),
              ]
          )
      else:
          pipeline = Pipeline(
              steps=[
                  ("preprocessor", feat_pipe),
                  (
                      "model",
                      RandomForestRegressor(
                          n_estimators=10, max_depth=5
                      ),
                  ),
              ]
          )
  
      return pipeline
  
file_path: responsible-ai-toolbox/apps/dashboard/src/model-assessment/model.py
imports: import json
  import numpy
  import pandas
  from sklearn.compose import ColumnTransformer
  from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
  from sklearn.impute import SimpleImputer
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import OneHotEncoder, StandardScaler
  from raiutils.data_processing import convert_to_list
label_desc: Use image node_id 2 for calling a global function with example usage: create_pipeline(X, task_type) and returns: pipeline