code: def express(expr, frame, frame2=None, variables=False):
      """
      Global function for 'express' functionality.
  
      Re-expresses a Vector, scalar(sympyfiable) or Dyadic in given frame.
  
      Refer to the local methods of Vector and Dyadic for details.
      If 'variables' is True, then the coordinate variables (CoordinateSym
      instances) of other frames present in the vector/scalar field or
      dyadic expression are also substituted in terms of the base scalars of
      this frame.
  
      Parameters
      ==========
  
      expr : Vector/Dyadic/scalar(sympyfiable)
          The expression to re-express in ReferenceFrame 'frame'
  
      frame: ReferenceFrame
          The reference frame to express expr in
  
      frame2 : ReferenceFrame
          The other frame required for re-expression(only for Dyadic expr)
  
      variables : boolean
          Specifies whether to substitute the coordinate variables present
          in expr, in terms of those of frame
  
      Examples
      ========
  
      >>> from sympy.physics.vector import ReferenceFrame, outer, dynamicsymbols
      >>> from sympy.physics.vector import init_vprinting
      >>> init_vprinting(pretty_print=False)
      >>> N = ReferenceFrame('N')
      >>> q = dynamicsymbols('q')
      >>> B = N.orientnew('B', 'Axis', [q, N.z])
      >>> d = outer(N.x, N.x)
      >>> from sympy.physics.vector import express
      >>> express(d, B, N)
      cos(q)*(B.x|N.x) - sin(q)*(B.y|N.x)
      >>> express(B.x, N)
      cos(q)*N.x + sin(q)*N.y
      >>> express(N[0], B, variables=True)
      B_x*cos(q) - B_y*sin(q)
  
      """
  
      _check_frame(frame)
  
      if expr == 0:
          return expr
  
      if isinstance(expr, Vector):
          # Given expr is a Vector
          if variables:
              # If variables attribute is True, substitute the coordinate
              # variables in the Vector
              frame_list = [x[-1] for x in expr.args]
              subs_dict = {}
              for f in frame_list:
                  subs_dict.update(f.variable_map(frame))
              expr = expr.subs(subs_dict)
          # Re-express in this frame
          outvec = Vector([])
          for i, v in enumerate(expr.args):
              if v[1] != frame:
                  temp = frame.dcm(v[1]) * v[0]
                  if Vector.simp:
                      temp = temp.applyfunc(
                          lambda x: trigsimp(x, method="fu")
                      )
                  outvec += Vector([(temp, frame)])
              else:
                  outvec += Vector([v])
          return outvec
  
      if isinstance(expr, Dyadic):
          if frame2 is None:
              frame2 = frame
          _check_frame(frame2)
          ol = Dyadic(0)
          for i, v in enumerate(expr.args):
              ol += express(v[0], frame, variables=variables) * (
                  express(v[1], frame, variables=variables)
                  | express(v[2], frame2, variables=variables)
              )
          return ol
  
      else:
          if variables:
              # Given expr is a scalar field
              frame_set = set()
              expr = sympify(expr)
              # Substitute all the coordinate variables
              for x in expr.free_symbols:
                  if isinstance(x, CoordinateSym) and x.frame != frame:
                      frame_set.add(x.frame)
              subs_dict = {}
              for f in frame_set:
                  subs_dict.update(f.variable_map(frame))
              return expr.subs(subs_dict)
          return expr
  
file_path: sympy/sympy/physics/vector/functions.py
imports: from functools import reduce
  from sympy import sympify, diff, sin, cos, Matrix, symbols, Function, S, Symbol
  from sympy.integrals.integrals import integrate
  from sympy.simplify.trigsimp import trigsimp
  from .vector import Vector, _check_vector
  from .frame import CoordinateSym, _check_frame
  from .dyadic import Dyadic
  from .printing import vprint, vsprint, vpprint, vlatex, init_vprinting
  from sympy.utilities.iterables import iterable
  from sympy.utilities.misc import translate
label_desc: Use image node_id 3 for calling a global function with example usage: express(expr, frame, frame2, variables) and returns: expr, outvec, ol, expr, expr