code: def _target_feature_weights(
      leaf_ids, tree_dumps, feature_names, xgb_feature_names
  ):
      feature_weights = np.zeros(len(feature_names))
      # All trees in XGBoost give equal contribution to the prediction:
      # it is equal to sum of "leaf" values in leafs
      # before applying loss-specific function
      # (e.g. logistic for "binary:logistic" loss).
      score = 0
      for text_dump, leaf_id in zip(tree_dumps, leaf_ids):
          leaf = _indexed_leafs(_parse_tree_dump(text_dump))[leaf_id]
          score += leaf["leaf"]
          path = [leaf]
          while "parent" in path[-1]:
              path.append(path[-1]["parent"])
          path.reverse()
          # Check how each split changes "leaf" value
          for node, child in zip(path, path[1:]):
              idx = xgb_feature_names[node["split"]]
              feature_weights[idx] += child["leaf"] - node["leaf"]
          # Root "leaf" value is interpreted as bias
          feature_weights[feature_names.bias_idx] += path[0]["leaf"]
      return score, feature_weights
  
imports: from __future__ import absolute_import
  from functools import partial
  import re
  from typing import Any, Dict, List, Tuple, Optional, Pattern
  import numpy
  import scipy.sparse
  from xgboost import XGBClassifier, XGBRegressor, Booster, DMatrix
  from eli5.explain import explain_weights, explain_prediction
  from eli5.sklearn.utils import add_intercept, get_X, get_X0, handle_vec, predict_proba
  from eli5.utils import is_sparse_vector
  from eli5._decision_path import get_decision_path_explanation
  from eli5._feature_importances import get_feature_importance_explanation
label_desc: Use image node_id 5 for calling a global function with example usage: _target_feature_weights(leaf_ids, tree_dumps, feature_names, xgb_feature_names) and returns: score,  feature_weights