code: def _xgb_n_targets(xgb):
      # type: (...) -> int
      if isinstance(xgb, XGBClassifier):
          return 1 if xgb.n_classes_ == 2 else xgb.n_classes_
      elif isinstance(xgb, XGBRegressor):
          return 1
      else:
          raise TypeError
  
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 8 for calling a global function with example usage: _xgb_n_targets(xgb) and returns: unknown, int