code: def create_expand_pow_optimization(
      limit, *, base_req=lambda b: b.is_symbol
  ):
      """Creates an instance of :class:`ReplaceOptim` for expanding ``Pow``.
  
      Explanation
      ===========
  
      The requirements for expansions are that the base needs to be a symbol
      and the exponent needs to be an Integer (and be less than or equal to
      ``limit``).
  
      Parameters
      ==========
  
      limit : int
           The highest power which is expanded into multiplication.
      base_req : function returning bool
           Requirement on base for expansion to happen, default is to return
           the ``is_symbol`` attribute of the base.
  
      Examples
      ========
  
      >>> from sympy import Symbol, sin
      >>> from sympy.codegen.rewriting import create_expand_pow_optimization
      >>> x = Symbol('x')
      >>> expand_opt = create_expand_pow_optimization(3)
      >>> expand_opt(x**5 + x**3)
      x**5 + x*x*x
      >>> expand_opt(x**5 + x**3 + sin(x)**3)
      x**5 + sin(x)**3 + x*x*x
      >>> opt2 = create_expand_pow_optimization(3, base_req=lambda b: not b.is_Function)
      >>> opt2((x+1)**2 + sin(x)**2)
      sin(x)**2 + (x + 1)*(x + 1)
  
      """
      return ReplaceOptim(
          lambda e: e.is_Pow
          and base_req(e.base)
          and e.exp.is_Integer
          and abs(e.exp) <= limit,
          lambda p: (
              UnevaluatedExpr(Mul(*([p.base] * +p.exp), evaluate=False))
              if p.exp > 0
              else 1
              / UnevaluatedExpr(
                  Mul(*([p.base] * -p.exp), evaluate=False)
              )
          ),
      )
  
imports: from sympy.core.function import expand_log
  from sympy.core.singleton import S
  from sympy.core.symbol import Wild
  from sympy.functions.elementary.complexes import sign
  from sympy.functions.elementary.exponential import exp, log
  from sympy.functions.elementary.miscellaneous import Max, Min
  from sympy.functions.elementary.trigonometric import cos, sin, sinc
  from sympy.assumptions import Q, ask
  from sympy.codegen.cfunctions import log1p, log2, exp2, expm1
  from sympy.codegen.matrix_nodes import MatrixSolve
  from sympy.core.expr import UnevaluatedExpr
  from sympy.core.power import Pow
  from sympy.codegen.numpy_nodes import logaddexp, logaddexp2
  from sympy.codegen.scipy_nodes import cosm1, powm1
  from sympy.core.mul import Mul
  from sympy.matrices.expressions.matexpr import MatrixSymbol
  from sympy.utilities.iterables import sift
label_desc: Use image node_id 2 for calling a global function with example usage: create_expand_pow_optimization(limit) and returns: ReplaceOptim