code: def ratio_reduce(
      total: int,
      ratios: List[int],
      maximums: List[int],
      values: List[int],
  ) -> List[int]:
      """Divide an integer total in to parts based on ratios.
  
      Args:
          total (int): The total to divide.
          ratios (List[int]): A list of integer ratios.
          maximums (List[int]): List of maximums values for each slot.
          values (List[int]): List of values
  
      Returns:
          List[int]: A list of integers guaranteed to sum to total.
      """
      ratios = [
          ratio if _max else 0 for ratio, _max in zip(ratios, maximums)
      ]
      total_ratio = sum(ratios)
      if not total_ratio:
          return values[:]
      total_remaining = total
      result: List[int] = []
      append = result.append
      for ratio, maximum, value in zip(ratios, maximums, values):
          if ratio and total_ratio > 0:
              distributed = min(
                  maximum, round(ratio * total_remaining / total_ratio)
              )
              append(value - distributed)
              total_remaining -= distributed
              total_ratio -= ratio
          else:
              append(value)
      return result
  
file_path: rich/rich/_ratio.py
imports: import sys
  from fractions import Fraction
  from math import ceil
  from typing import cast, List, Optional, Sequence
label_desc: Use image node_id 2 for calling a global function with example usage: ratio_reduce(total, ratios, maximums, values) and returns: result, values