code: def build_explainer(explainer_config):
      if isinstance(explainer_config, (Path, str)) and str(
          explainer_config
      ).endswith(".yaml"):
          config = yaml.safe_load(open(str(explainer_config), "r"))
      elif isinstance(explainer_config, dict):
          config = explainer_config
      assert (
          "explainer" in config
      ), "Please pass a proper explainer.yaml config file that starts with `explainer:`!"
      config = explainer_config["explainer"]
  
      print(
          f"explainerdashboard ===> Loading model from {config['modelfile']}"
      )
      model = pickle.load(open(config["modelfile"], "rb"))
  
      print(
          f"explainerdashboard ===> Loading data from {config['datafile']}"
      )
      if str(config["datafile"]).endswith(".csv"):
          df = pd.read_csv(config["datafile"])
      elif str(config["datafile"]).endswith(".parquet"):
          df = pd.read_parquet(config["datafile"])
      else:
          raise ValueError(
              "datafile should either be a .csv or .parquet!"
          )
  
      print(
          f"explainerdashboard ===> Using column {config['data_target']} to generate X, y "
      )
      target_col = config["data_target"]
      X = df.drop(target_col, axis=1)
      y = df[target_col]
  
      if config["data_index"] is not None:
          print(
              f"explainerdashboard ===> Generating index from column {config['data_index']}"
          )
          assert config["data_index"] in X.columns, (
              f"Cannot find data_index column ({config['data_index']})"
              f" in datafile ({config['datafile']})!"
              "Please set it to the proper index column name, or set it to null"
          )
          X = X.set_index(config["data_index"])
  
      params = config["params"]
  
      if config["explainer_type"] == "classifier":
          print(
              f"explainerdashboard ===> Generating ClassifierExplainer..."
          )
          explainer = ClassifierExplainer(model, X, y, **params)
      elif config["explainer_type"] == "regression":
          print(
              f"explainerdashboard ===> Generating RegressionExplainer..."
          )
          explainer = ClassifierExplainer(model, X, y, **params)
      return explainer
  
imports: import os
  import webbrowser
  from pathlib import Path
  from importlib import import_module
  from copy import deepcopy
  import pickle
  import oyaml
  import pandas
  import joblib
  import click
  import waitress
  from explainerdashboard import *
  from explainerdashboard.explainers import BaseExplainer
  from explainerdashboard.dashboards import ExplainerDashboard
label_desc: Use image node_id 1 for calling a global function with example usage: build_explainer(explainer_config) and returns: explainer