code: def repair_features(
      features: pd.DataFrame,
      sensitive_attribute: pd.Series,
      definition: int,
      repair_level: float,
      group_quantiles: dict,
      global_quantiles: dict,
  ) -> pd.DataFrame:
      """
      Transform the features conditioned of protected attribute to match the global
      distribution.
  
      Parameters
      ----------
      features : pd.DataFrame
          The features.
      sensitive_attribute : pd.Series
          The sensitive attribute.
      definition : int
          The number of quantiles to use.
      repair_level : float
          The level of repair to apply. 0 means no repair, 1 means full repair.
      group_quantiles : dict
          The quantiles per group.
      global_quantiles : dict
          The global quantiles.
      """
      features_repaired = features.copy()
  
      quantile_points = np.linspace(0, 1, definition)
      for column in global_quantiles.keys():
          # Calculate the quantile of every point for every group (vectorized)
          interpolation_quantiles = {}
          # Also calculate the global distribution value at that quantile
          global_values = {}
          # After, calculate the corrected value for every point
          corrected_values = {}
          for group in sensitive_attribute.unique():
              interpolation_quantiles[group] = (
                  np.interp(
                      features_repaired[column],
                      group_quantiles[column][group],
                      quantile_points,
                  )
                  + np.interp(
                      -features_repaired[column],
                      -group_quantiles[column][group][::-1],
                      quantile_points[::-1],
                  )
              ) / 2
              global_values[group] = np.interp(
                  interpolation_quantiles[group],
                  quantile_points,
                  global_quantiles[column],
              )
              corrected_values[group] = global_values[
                  group
              ] * repair_level + features_repaired[column].values * (
                  1 - repair_level
              )
  
          repaired_column = [
              corrected_values[group][index]
              for index, group in enumerate(sensitive_attribute)
          ]
          features_repaired[column] = repaired_column
      return features_repaired
  
imports: import numpy
  import pandas
label_desc: Use image node_id 2 for calling a global function with example usage: repair_features(features, sensitive_attribute, definition, repair_level, group_quantiles, global_quantiles) and returns: features_repaired