code: def _predict_forest(model, X, joint_contribution=False):
      """
      For a given RandomForestRegressor, RandomForestClassifier,
      ExtraTreesRegressor, or ExtraTreesClassifier returns a triple of
      [prediction, bias and feature_contributions], such that prediction ≈ bias +
      feature_contributions.
      """
  
      if joint_contribution:
          biases = []
          contributions = []
          predictions = []
  
          for tree in model.estimators_:
              pred, bias, contribution = _predict_tree(
                  tree, X, joint_contribution=joint_contribution
              )
  
              biases.append(bias)
              contributions.append(contribution)
              predictions.append(pred)
  
          total_contributions = []
  
          for i in range(len(X)):
              contr = {}
              for j, dct in enumerate(contributions):
                  for k in set(dct[i]).union(set(contr.keys())):
                      contr[k] = (
                          contr.get(k, 0) * j + dct[i].get(k, 0)
                      ) / (j + 1)
  
              total_contributions.append(contr)
  
          for i, item in enumerate(contribution):
              total_contributions[i]
              sm = sum([v for v in contribution[i].values()])
  
          return (
              np.mean(predictions, axis=0),
              np.mean(biases, axis=0),
              total_contributions,
          )
      else:
          mean_pred = None
          mean_bias = None
          mean_contribution = None
  
          for i, tree in enumerate(model.estimators_):
              pred, bias, contribution = _predict_tree(tree, X)
  
              if i < 1:  # first iteration
                  mean_bias = bias
                  mean_contribution = contribution
                  mean_pred = pred
              else:
                  mean_bias = _iterative_mean(i, mean_bias, bias)
                  mean_contribution = _iterative_mean(
                      i, mean_contribution, contribution
                  )
                  mean_pred = _iterative_mean(i, mean_pred, pred)
  
          return mean_pred, mean_bias, mean_contribution
  
file_path: treeinterpreter/treeinterpreter/treeinterpreter.py
imports: import numpy
  import sklearn
  from sklearn.ensemble import RandomForestClassifier, ExtraTreesClassifier, RandomForestRegressor, ExtraTreesRegressor
  from sklearn.tree import DecisionTreeRegressor, DecisionTreeClassifier, _tree
  from distutils.version import LooseVersion
label_desc: Use image node_id 4 for calling a global function with example usage: _predict_forest(model, X, joint_contribution) and returns: np,  np,  total_contributions, mean_pred,  mean_bias,  mean_contribution