How would you implement power management strategies such as sleep modes, clock gating, and power domains for a mobile device?
Implement power_plan(components, active, idle_seconds, battery_saver) using the supplied component dependencies and policies. Return the components that must sleep, clocks that remain enabled, and power domains that remain powered; battery saver halves each sleep threshold, with a minimum effective threshold of one second.
Each component specifies domain, clock, dependencies, and integer sleep_threshold; active and idle_seconds are mappings keyed by component name. An active component also requires every transitive dependency, and a domain or clock remains enabled when at least one required component uses it.
def power_plan(components, active, idle_seconds, battery_saver):