code: def clean_init_score_and_X(
      link,
      link_param,
      init_score,
      X,
      feature_names,
      feature_types,
      n_samples=None,
      sample_source="y",
  ):
      if init_score is None:
          X, n_samples = preclean_X(
              X, feature_names, feature_types, n_samples, sample_source
          )
          return None, X, n_samples
  
      if is_classifier(init_score):
          probs = clean_dimensions(
              init_score.predict_proba(X), "init_score"
          )
          X, n_samples = preclean_X(
              X, feature_names, feature_types, n_samples, sample_source
          )
          if (
              n_samples == 1
          ):  # then the sample dimension would have been eliminated
              if probs.ndim != 1:
                  msg = "init_score.predict_proba(X) returned inconsistent number of dimensions"
                  _log.error(msg)
                  raise ValueError(msg)
              if probs.shape[0] <= 1:  # 0 or 1 means 1 class
                  # only 1 class to predict means perfect prediction, and no scores for EBMs
                  # do not check if probs are all one in case there is floating point noise
                  return np.empty((1, 0), np.float64), X, n_samples
              probs = probs.reshape([1] + probs.shape)
          else:
              if probs.shape[0] == 0:
                  # having any dimension as zero length probably means 1 class, so treat it that way
                  return (
                      np.empty((n_samples, 0), np.float64),
                      X,
                      n_samples,
                  )
              if probs.shape[0] != n_samples:
                  msg = "init_score.predict_proba(X) returned inconsistent number of samples compared to X"
                  _log.error(msg)
                  raise ValueError(msg)
              if probs.ndim == 1:
                  # only 1 class to predict means perfect prediction, and no scores for EBMs
                  # do not check if probs are all one in case there is floating point noise
                  return (
                      np.empty((n_samples, 0), np.float64),
                      X,
                      n_samples,
                  )
          probs = probs.astype(np.float64, copy=False)
          init_score = link_func(probs, link, link_param)
          return init_score, X, n_samples
      elif is_regressor(init_score):
          predictions = clean_dimensions(
              init_score.predict(X), "init_score"
          )
          X, n_samples = preclean_X(
              X, feature_names, feature_types, n_samples, sample_source
          )
          if predictions.ndim != 1:
              msg = "init_score.predict(X) must have only 1 dimension"
              _log.error(msg)
              raise ValueError(msg)
          if predictions.shape[0] != n_samples:
              msg = "init_score.predict(X) returned inconsistent number of samples compared to X"
              _log.error(msg)
              raise ValueError(msg)
          predictions = predictions.astype(np.float64, copy=False)
          init_score = link_func(predictions, link, link_param)
          return init_score, X, n_samples
  
      init_score = clean_dimensions(init_score, "init_score")
      X, n_samples = preclean_X(
          X, feature_names, feature_types, n_samples, sample_source
      )
      if (
          n_samples == 1
      ):  # then the sample dimension would have been eliminated
          if init_score.ndim != 1:
              msg = "init_score has an inconsistent number of samples compared to X"
              _log.error(msg)
              raise ValueError(msg)
          if init_score.shape[0] != 1:
              init_score = init_score.reshape([1] + init_score.shape)
      else:
          if init_score.shape[0] == 0:
              # must be a 1 class problem. We use 1 score, but others might use 0.
              return (
                  np.full(n_samples, -np.inf, np.float64),
                  X,
                  n_samples,
              )
          if init_score.shape[0] != n_samples:
              msg = "init_score has an inconsistent number of samples compared to X"
              _log.error(msg)
              raise ValueError(msg)
      init_score = init_score.astype(np.float64, copy=False)
      return init_score, X, n_samples
  
file_path: interpret/python/interpret-core/interpret/utils/_clean_simple.py
imports: import numpy
  import numpy.ma
  from sklearn.base import is_classifier, is_regressor
  from ._clean_x import preclean_X
  from ._link import link_func
  import logging
label_desc: Use image node_id 4 for calling a global function with example usage: clean_init_score_and_X(link, link_param, init_score, X, feature_names, feature_types, n_samples, sample_source) and returns: init_score,  X,  n_samples, None,  X,  n_samples, init_score,  X,  n_samples, init_score,  X,  n_samples, np,  X,  n_samples, np,  X,  n_samples, np,  X,  n_samples, np,  X,  n_samples