code: def sample(X, nsamples=100, random_state=0):
      """Performs sampling without replacement of the input data ``X``.
  
      This is a simple wrapper over scikit-learn's ``shuffle`` function.
      It is used mainly to downsample ``X`` for use as a background
      dataset in SHAP :class:`.Explainer` and its subclasses.
  
      .. versionchanged :: 0.42
          The behaviour of ``sample`` was changed from sampling *with* replacement to sampling
          *without* replacement.
          Note that reproducibility might be broken when using this function pre- and post-0.42,
          even with the specification of ``random_state``.
  
      Parameters
      ----------
      X : array-like
          Data to sample from. Input data can be arrays, lists, dataframes
          or scipy sparse matrices with a consistent first dimension.
  
      nsamples : int
          Number of samples to generate from ``X``.
  
      random_state :
          Determines random number generation for shuffling the data. Use this to
          ensure reproducibility across multiple function calls.
      """
      if hasattr(X, "shape"):
          over_count = nsamples >= X.shape[0]
      else:
          over_count = nsamples >= len(X)
  
      if over_count:
          return X
      return sklearn.utils.shuffle(
          X, n_samples=nsamples, random_state=random_state
      )
  
imports: import copy
  import os
  import re
  import sys
  from contextlib import contextmanager
  import numpy
  import pandas
  import scipy.special
  import sklearn
label_desc: Use image node_id 8 for calling a global function with example usage: sample(X, nsamples, random_state) and returns: sklearn, X