code: def _missing_values_set_to_nan(values, missing_value, sparse_missing):
      """Return a copy of values where missing values (equal to missing_value)
      are replaced to nan according. If sparse_missing is True,
      entries missing in a sparse matrix will also be set to nan.
      Sparse matrices will be converted to dense format.
      """
      if sp.issparse(values):
          assert values.shape[0] == 1
      if sparse_missing and sp.issparse(values) and missing_value != 0:
          # Nothing special needs to be done for missing.value == 0 because
          # missing values are assumed to be zero in sparse matrices.
          values_coo = values.tocoo()
          values = values.toarray()[0]
          missing_mask = values == 0
          # fix for possible zero values
          missing_mask[values_coo.col] = False
          values[missing_mask] = np.nan
      elif is_sparse_vector(values):
          values = values.toarray()[0]
      else:
          values = values.copy()
      if not np.isnan(missing_value):
          values[values == missing_value] = np.nan
      return values
  
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 12 for calling a global function with example usage: _missing_values_set_to_nan(values, missing_value, sparse_missing) and returns: values