def balance_classes(sm, X, y):
    """
    Args:
        sm (imblearn class): this is an imbalance learn oversampling or
        undersampling class
        X (2d numpy array): this is the feature matrix
        y (1d numpy array): this is the array of the targets
    Returns:
        X (2d numpy array): this is the balanced feature matrix
        y (1d numpy array): this is the corresponding balanced target array
    Returns X and y after being fit with the resampling method
    """
    X, y = sm.fit_sample(X, y)
    return X, y