code: def local_interactions(
      explainer,
      new_observation,
      interaction_preference,
      type,
      order,
      keep_distributions,
  ):
      # here one can add model and data and new observation
      # just in case only some variables are specified
      # this will work only for data.frames
  
      # set target
      target_yhat = explainer.predict(new_observation)
      baseline_yhat = np.mean(explainer.predict(explainer.data))
  
      # 1d changes
      # how the average would change if single variable is changed
      average_yhats = calculate_1d_changes(explainer, new_observation)
      diffs_1d = average_yhats - baseline_yhat
  
      if type == "2d":
          # impact summary for 1d variables
          feature_path_1d = pd.DataFrame(
              {
                  "diff": diffs_1d,
                  "adiff": np.abs(diffs_1d),
                  "diff_norm": diffs_1d,
                  "adiff_norm": np.abs(diffs_1d),
                  "ind1": np.arange(len(explainer.data.columns)),
                  "ind2": None,
              }
          )
  
          p = explainer.data.shape[1]
          inds = pd.DataFrame(
              {
                  "ind1": np.hstack(
                      [np.arange(i, p) for i in range(1, p)]
                  ),
                  "ind2": np.hstack(
                      [np.repeat(i - 1, p - i) for i in range(1, p)]
                  ),
              }
          )
  
          # 2d changes
          # how the average would change if two variables are changed
          (
              average_yhats_2d,
              average_yhats_2d_norm,
          ) = calculate_2d_changes(
              explainer, new_observation, inds, diffs_1d
          )
  
          diffs_2d = average_yhats_2d - baseline_yhat
          diffs_2d_norm = average_yhats_2d_norm - baseline_yhat
  
          # impact summary for 2d variables
          # large interaction_preference force to use interactions
  
          feature_path_2d = pd.DataFrame(
              {
                  "diff": diffs_2d,
                  "adiff": np.abs(diffs_2d) * interaction_preference,
                  "diff_norm": diffs_2d_norm,
                  "adiff_norm": np.abs(diffs_2d_norm)
                  * interaction_preference,
                  "ind1": inds.loc[:, "ind1"].values,
                  "ind2": inds.loc[:, "ind2"].values,
              }
          )
  
          feature_path = pd.concat((feature_path_1d, feature_path_2d))
  
      else:
          # different definition
          feature_path = pd.DataFrame(
              {"diff": diffs_1d, "ind1": np.arange(diffs_1d.shape[0])}
          )
  
      # how variables shall be ordered in the BD plot?
      feature_path = create_ordered_path(
          feature_path, average_yhats.index, type, order
      )
  
      # Now we know the path, so we can calculate contributions
      # set variable indicators
      result, yhats = calculate_contributions_along_path(
          explainer,
          new_observation,
          feature_path,
          baseline_yhat,
          target_yhat,
          type,
          keep_distributions,
      )
  
      result = pd.DataFrame(result)
  
      if keep_distributions:
          yhats_distributions = pd.DataFrame(
              {
                  "variable_name": "all data",
                  "variable": "all data",
                  "id": np.arange(0, explainer.data.shape[0]),
                  "prediction": explainer.predict(explainer.data),
                  "label": explainer.label,
              }
          )
  
          yhats_distributions = pd.concat([yhats_distributions, yhats])
  
      yhats_distributions = (
          yhats_distributions if keep_distributions else None
      )
  
      return result, yhats_distributions
  
file_path: DALEX/python/dalex/dalex/predict_explanations/_break_down/utils.py
imports: from copy import deepcopy
  import numpy
  import pandas
label_desc: Use image node_id 1 for calling a global function with example usage: local_interactions(explainer, new_observation, interaction_preference, type, order, keep_distributions) and returns: result,  yhats_distributions