code: def switch(
      key: Callable[[_S], _T], ruledict: Mapping[_T, Callable[[_S], _S]]
  ) -> Callable[[_S], _S]:
      """Select a rule based on the result of key called on the function"""
  
      def switch_rl(expr: _S) -> _S:
          rl = ruledict.get(key(expr), identity)
          return rl(expr)
  
      return switch_rl
  
file_path: sympy/sympy/strategies/core.py
imports: from __future__ import annotations
  from collections.abc import Callable, Mapping
  from typing import TypeVar
  from sys import stdout
label_desc: Use image node_id 10 for calling a global function with example usage: switch(key, ruledict) and returns: switch_rl, rl