code: def resample_training_data(X_train, Y_train, A_train):
      """Down-sample the majority class in the training dataset to produce a
      balanced dataset with a 50/50 split in the predictive labels.
  
      Parameters:
      X_train: The training split of the features
      Y_train: The training split of the target labels
      A_train: The training split of the sensitive features
  
      Returns:
      Tuple of X_train, Y_train, A_train where each dataset has been re-balanced.
      """
      negative_ids = Y_train[Y_train == 0].index
      positive_ids = Y_train[Y_train == 1].index
      balanced_ids = positive_ids.union(
          np.random.choice(a=negative_ids, size=len(positive_ids))
      )
  
      X_train = X_train.loc[balanced_ids, :]
      Y_train = Y_train.loc[balanced_ids]
      A_train = A_train.loc[balanced_ids]
      return X_train, Y_train, A_train
  
imports: import numpy
  import pandas
  import matplotlib.pyplot
  import lightgbm
  from sklearn.metrics import balanced_accuracy_score, roc_auc_score
  from sklearn.metrics import confusion_matrix
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import StandardScaler
  from fairlearn.metrics import MetricFrame
  from fairlearn.metrics import count, selection_rate, equalized_odds_difference, false_positive_rate, false_negative_rate
  from fairlearn.postprocessing import ThresholdOptimizer
  from fairlearn.reductions import ExponentiatedGradient
  from fairlearn.reductions import EqualizedOdds
  from sklearn.model_selection import train_test_split
  import warnings
label_desc: Use image node_id 1 for calling a global function with example usage: resample_training_data(X_train, Y_train, A_train) and returns: X_train,  Y_train,  A_train