code: def _update_tree_feature_weights(X, feature_names, clf, feature_weights):
      
      tree_value = clf.tree_.value
      if tree_value.shape[1] == 1:
          squeeze_axis = 1
      else:
          assert tree_value.shape[2] == 1
          squeeze_axis = 2
      tree_value = np.squeeze(tree_value, axis=squeeze_axis)
      tree_feature = clf.tree_.feature
      _, indices = clf.decision_path(X).nonzero()
      if isinstance(clf, DecisionTreeClassifier):
          norm = lambda x: x / x.sum()
      else:
          norm = lambda x: x
      feature_weights[feature_names.bias_idx] += norm(tree_value[0])
      for parent_idx, child_idx in zip(indices, indices[1:]):
          assert tree_feature[parent_idx] >= 0
          feature_idx = tree_feature[parent_idx]
          diff = norm(tree_value[child_idx]) - norm(tree_value[parent_idx])
          feature_weights[feature_idx] += diff
docs: Update tree feature weights using decision path method.