code: def optimize(expr, optimizations):
      """Apply optimizations to an expression.
  
      Parameters
      ==========
  
      expr : expression
      optimizations : iterable of ``Optimization`` instances
          The optimizations will be sorted with respect to ``priority`` (highest first).
  
      Examples
      ========
  
      >>> from sympy import log, Symbol
      >>> from sympy.codegen.rewriting import optims_c99, optimize
      >>> x = Symbol('x')
      >>> optimize(log(x+3)/log(2) + log(x**2 + 1), optims_c99)
      log1p(x**2) + log2(x + 3)
  
      """
  
      for optim in sorted(
          optimizations, key=lambda opt: opt.priority, reverse=True
      ):
          new_expr = optim(expr)
          if optim.cost_function is None:
              expr = new_expr
          else:
              expr = optim.cheapest(expr, new_expr)
      return expr
  
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 1 for calling a global function with example usage: optimize(expr, optimizations) and returns: expr