code: def expanded_X_y_sample_weights(
      X,
      y_proba,
      expand_factor=10,
      sample_weight=None,
      shuffle=True,
      random_state=None,
  ):
      """
      scikit-learn can't optimize cross-entropy directly if target
      probability values are not indicator vectors.
      As a workaround this function expands the dataset according to
      target probabilities. ``expand_factor=None`` means no dataset
      expansion.
      """
      rng = check_random_state(random_state)
      if expand_factor:
          if sample_weight is not None:
              X, y, sample_weight = zip(
                  *expand_dataset(
                      X,
                      y_proba,
                      factor=expand_factor,
                      random_state=rng,
                      extra_arrays=[sample_weight],
                  )
              )
          else:
              X, y = zip(
                  *expand_dataset(
                      X, y_proba, factor=expand_factor, random_state=rng
                  )
              )
      else:
          y = y_proba.argmax(axis=1)
  
      if isinstance(X, (list, tuple)) and len(X) and issparse(X[0]):
          X = vstack(X)
  
      if shuffle:
          if sample_weight is not None:
              X, y, sample_weight = _shuffle(
                  X, y, sample_weight, random_state=rng
              )
          else:
              X, y = _shuffle(X, y, random_state=rng)
      return X, y, sample_weight
  
imports: from __future__ import absolute_import
  from typing import List, Any
  import numpy
  from scipy.stats import entropy
  from sklearn.pipeline import Pipeline
  from sklearn.utils import check_random_state, issparse
  from sklearn.utils.metaestimators import if_delegate_has_method
  from sklearn.utils import shuffle
  from eli5.utils import vstack
  from eli5.sklearn.utils import sklearn_version
label_desc: Use image node_id 5 for calling a global function with example usage: expanded_X_y_sample_weights(X, y_proba, expand_factor, sample_weight, shuffle, random_state) and returns: X,  y,  sample_weight