code: def express(expr, system, system2=None, variables=False):
      """
      Global function for 'express' functionality.
  
      Re-expresses a Vector, Dyadic or scalar(sympyfiable) in the given
      coordinate system.
  
      If 'variables' is True, then the coordinate variables (base scalars)
      of other coordinate systems present in the vector/scalar field or
      dyadic are also substituted in terms of the base scalars of the
      given system.
  
      Parameters
      ==========
  
      expr : Vector/Dyadic/scalar(sympyfiable)
          The expression to re-express in CoordSys3D 'system'
  
      system: CoordSys3D
          The coordinate system the expr is to be expressed in
  
      system2: CoordSys3D
          The other coordinate system required for re-expression
          (only for a Dyadic Expr)
  
      variables : boolean
          Specifies whether to substitute the coordinate variables present
          in expr, in terms of those of parameter system
  
      Examples
      ========
  
      >>> from sympy.vector import CoordSys3D
      >>> from sympy import Symbol, cos, sin
      >>> N = CoordSys3D('N')
      >>> q = Symbol('q')
      >>> B = N.orient_new_axis('B', q, N.k)
      >>> from sympy.vector import express
      >>> express(B.i, N)
      (cos(q))*N.i + (sin(q))*N.j
      >>> express(N.x, B, variables=True)
      B.x*cos(q) - B.y*sin(q)
      >>> d = N.i.outer(N.i)
      >>> express(d, B, N) == (cos(q))*(B.i|N.i) + (-sin(q))*(B.j|N.i)
      True
  
      """
  
      if expr in (0, Vector.zero):
          return expr
  
      if not isinstance(system, CoordSys3D):
          raise TypeError(
              "system should be a CoordSys3D \
                          instance"
          )
  
      if isinstance(expr, Vector):
          if system2 is not None:
              raise ValueError(
                  "system2 should not be provided for \
                                  Vectors"
              )
          # Given expr is a Vector
          if variables:
              # If variables attribute is True, substitute
              # the coordinate variables in the Vector
              system_list = {
                  x.system for x in expr.atoms(BaseScalar, BaseVector)
              } - {system}
              subs_dict = {}
              for f in system_list:
                  subs_dict.update(f.scalar_map(system))
              expr = expr.subs(subs_dict)
          # Re-express in this coordinate system
          outvec = Vector.zero
          parts = expr.separate()
          for x in parts:
              if x != system:
                  temp = system.rotation_matrix(x) * parts[x].to_matrix(
                      x
                  )
                  outvec += matrix_to_vector(temp, system)
              else:
                  outvec += parts[x]
          return outvec
  
      elif isinstance(expr, Dyadic):
          if system2 is None:
              system2 = system
          if not isinstance(system2, CoordSys3D):
              raise TypeError(
                  "system2 should be a CoordSys3D \
                              instance"
              )
          outdyad = Dyadic.zero
          var = variables
          for k, v in expr.components.items():
              outdyad += express(v, system, variables=var) * (
                  express(k.args[0], system, variables=var)
                  | express(k.args[1], system2, variables=var)
              )
  
          return outdyad
  
      else:
          if system2 is not None:
              raise ValueError(
                  "system2 should not be provided for \
                                  Vectors"
              )
          if variables:
              # Given expr is a scalar field
              system_set = set()
              expr = sympify(expr)
              # Substitute all the coordinate variables
              for x in expr.atoms(BaseScalar):
                  if x.system != system:
                      system_set.add(x.system)
              subs_dict = {}
              for f in system_set:
                  subs_dict.update(f.scalar_map(system))
              return expr.subs(subs_dict)
          return expr
  
imports: from sympy.vector.coordsysrect import CoordSys3D
  from sympy.vector.deloperator import Del
  from sympy.vector.scalar import BaseScalar
  from sympy.vector.vector import Vector, BaseVector
  from sympy.vector.operators import gradient, curl, divergence
  from sympy.core.function import diff
  from sympy.core.singleton import S
  from sympy.integrals.integrals import integrate
  from sympy.simplify.simplify import simplify
  from sympy.core import sympify
  from sympy.vector.dyadic import Dyadic
label_desc: Use image node_id 1 for calling a global function with example usage: express(expr, system, system2, variables) and returns: expr, outvec, outdyad, expr, expr