def METHOD_NAME(
    cls: type[System],
    system_definition: SystemDefinition,
    get_root_func: Optional[GetRootUnits] = None,
) -> System:
    if get_root_func is None:
        # TODO: kept for backwards compatibility
        get_root_func = cls._REGISTRY.get_root_units
    base_unit_names = {}
    derived_unit_names = []
    for new_unit, old_unit in system_definition.unit_replacements:
        if old_unit is None:
            old_unit_dict = to_units_container(get_root_func(new_unit)[1])
            if len(old_unit_dict) != 1:
                raise ValueError(
                    "The new unit must be a root dimension if not discarded unit is specified."
                )
            old_unit, value = dict(old_unit_dict).popitem()
            base_unit_names[old_unit] = {new_unit: 1 / value}
        else:
            # The old unit MUST be a root unit, if not raise an error.
            if old_unit != str(get_root_func(old_unit)[1]):
                raise ValueError(
                    f"The old unit {old_unit} must be a root unit "
                    f"in order to be replaced by new unit {new_unit}"
                )
            # Here we find new_unit expanded in terms of root_units
            new_unit_expanded = to_units_container(
                get_root_func(new_unit)[1], cls._REGISTRY
            )
            # We require that the old unit is present in the new_unit expanded
            if old_unit not in new_unit_expanded:
                raise ValueError("Old unit must be a component of new unit")
            # Here we invert the equation, in other words
            # we write old units in terms new unit and expansion
            new_unit_dict = {
                new_unit: -1 / value
                for new_unit, value in new_unit_expanded.items()
                if new_unit != old_unit
            }
            new_unit_dict[new_unit] = 1 / new_unit_expanded[old_unit]
            base_unit_names[old_unit] = new_unit_dict
    system = cls(system_definition.name)
    system.add_groups(*system_definition.using_group_names)
    system.base_units.update(**base_unit_names)
    system.derived_units |= set(derived_unit_names)
    return system