code: def roughly_balanced_bagging(X, y, replace=False):
      """Implementation of Roughly Balanced Bagging for binary problem."""
      # find the minority and majority classes
      class_counts = Counter(y)
      majority_class = max(class_counts, key=class_counts.get)
      minority_class = min(class_counts, key=class_counts.get)
  
      # compute the number of sample to draw from the majority class using
      # a negative binomial distribution
      n_minority_class = class_counts[minority_class]
      n_majority_resampled = np.random.negative_binomial(
          n=n_minority_class, p=0.5
      )
  
      # draw randomly with or without replacement
      majority_indices = np.random.choice(
          np.flatnonzero(y == majority_class),
          size=n_majority_resampled,
          replace=replace,
      )
      minority_indices = np.random.choice(
          np.flatnonzero(y == minority_class),
          size=n_minority_class,
          replace=replace,
      )
      indices = np.hstack([majority_indices, minority_indices])
  
      return X[indices], y[indices]
  
file_path: imbalanced-learn/examples/ensemble/plot_bagging_classifier.py
imports: from sklearn.datasets import make_classification
  import pandas
  from sklearn.ensemble import BaggingClassifier
  from sklearn.model_selection import cross_validate
  from imblearn.ensemble import BalancedBaggingClassifier
  from imblearn.under_sampling import RandomUnderSampler
  from imblearn.over_sampling import RandomOverSampler
  from imblearn.over_sampling import SMOTE
  from collections import Counter
  import numpy
  from imblearn import FunctionSampler
label_desc: Use image node_id 1 for calling a global function with example usage: roughly_balanced_bagging(X, y, replace) and returns: X,  y