code: def __correct_levels(
      result: np.ndarray,
      result_mid: np.ndarray,
      target_divisions: int,
      target_piece_size: int,
      reference_match_rms: float,
      config: Config,
  ) -> np.ndarray:
      debug_line()
      info(Code.INFO_CORRECTING_LEVELS)
  
      for step in range(1, config.rms_correction_steps + 1):
          debug(f"Applying RMS correction #{step}...")
          result_mid_clipped = clip(result_mid)
  
          _, clipped_rmses, clipped_average_rms = get_average_rms(
              result_mid_clipped,
              target_piece_size,
              target_divisions,
              "result",
          )
  
          _, result_mid_clipped_match_rms = get_lpis_and_match_rms(
              clipped_rmses, clipped_average_rms
          )
  
          (
              rms_coefficient,
              result_mid,
              result,
          ) = get_rms_c_and_amplify_pair(
              result_mid,
              result,
              result_mid_clipped_match_rms,
              reference_match_rms,
              config.min_value,
              "result",
          )
  
      return result
  
file_path: matchering/matchering/stages.py
imports: import numpy
  from .log import Code, info, debug, debug_line
  from .None import Config
  from .utils import to_db
  from .dsp import amplify, normalize, clip
  from .stage_helpers import normalize_reference, analyze_levels, get_fir, convolve, get_average_rms, get_lpis_and_match_rms, get_rms_c_and_amplify_pair
  from .limiter import limit
label_desc: Use image node_id 3 for calling a global function with example usage: __correct_levels(result, result_mid, target_divisions, target_piece_size, reference_match_rms, config) and returns: result