code: def sample_df(df: pd.DataFrame, n: int):
      """Sample n instances from the dataframe df."""
      if n < df.shape[0] + 1:
          replace = False
      else:
          replace = True
      return df.sample(n=n, replace=replace)
  
file_path: alibi-detect/alibi_detect/utils/data.py
imports: import numpy
  import pandas
  from typing import Tuple, Union
label_desc: Use image node_id 1 for calling a global function with example usage: sample_df(df, n) and returns: df