code: def msubs(expr, *sub_dicts, smart=False, **kwargs):
      """A custom subs for use on expressions derived in physics.mechanics.
  
      Traverses the expression tree once, performing the subs found in sub_dicts.
      Terms inside ``Derivative`` expressions are ignored:
  
      Examples
      ========
  
      >>> from sympy.physics.mechanics import dynamicsymbols, msubs
      >>> x = dynamicsymbols('x')
      >>> msubs(x.diff() + x, {x: 1})
      Derivative(x(t), t) + 1
  
      Note that sub_dicts can be a single dictionary, or several dictionaries:
  
      >>> x, y, z = dynamicsymbols('x, y, z')
      >>> sub1 = {x: 1, y: 2}
      >>> sub2 = {z: 3, x.diff(): 4}
      >>> msubs(x.diff() + x + y + z, sub1, sub2)
      10
  
      If smart=True (default False), also checks for conditions that may result
      in ``nan``, but if simplified would yield a valid expression. For example:
  
      >>> from sympy import sin, tan
      >>> (sin(x)/tan(x)).subs(x, 0)
      nan
      >>> msubs(sin(x)/tan(x), {x: 0}, smart=True)
      1
  
      It does this by first replacing all ``tan`` with ``sin/cos``. Then each
      node is traversed. If the node is a fraction, subs is first evaluated on
      the denominator. If this results in 0, simplification of the entire
      fraction is attempted. Using this selective simplification, only
      subexpressions that result in 1/0 are targeted, resulting in faster
      performance.
  
      """
  
      sub_dict = dict_merge(*sub_dicts)
      if smart:
          func = _smart_subs
      elif hasattr(expr, "msubs"):
          return expr.msubs(sub_dict)
      else:
          func = lambda expr, sub_dict: _crawl(
              expr, _sub_func, sub_dict
          )
      if isinstance(expr, (Matrix, Vector, Dyadic)):
          return expr.applyfunc(lambda x: func(x, sub_dict))
      else:
          return func(expr, sub_dict)
  
imports: from sympy.utilities import dict_merge
  from sympy.utilities.iterables import iterable
  from sympy.physics.vector import Dyadic, Vector, ReferenceFrame, Point, dynamicsymbols
  from sympy.physics.vector.printing import vprint, vsprint, vpprint, vlatex, init_vprinting
  from sympy.physics.mechanics.particle import Particle
  from sympy.physics.mechanics.rigidbody import RigidBody
  from sympy.simplify.simplify import simplify
  from sympy import Matrix, Mul, Derivative, sin, cos, tan, S
  from sympy.core.function import AppliedUndef
  from sympy.physics.mechanics.inertia import inertia, inertia_of_point_mass
  from sympy.utilities.exceptions import sympy_deprecation_warning
label_desc: Use image node_id 12 for calling a global function with example usage: msubs(expr) and returns: expr, func, expr