code: def convert_to(expr, target_units, unit_system="SI"):
      """
      Convert ``expr`` to the same expression with all of its units and quantities
      represented as factors of ``target_units``, whenever the dimension is compatible.
  
      ``target_units`` may be a single unit/quantity, or a collection of
      units/quantities.
  
      Examples
      ========
  
      >>> from sympy.physics.units import speed_of_light, meter, gram, second, day
      >>> from sympy.physics.units import mile, newton, kilogram, atomic_mass_constant
      >>> from sympy.physics.units import kilometer, centimeter
      >>> from sympy.physics.units import gravitational_constant, hbar
      >>> from sympy.physics.units import convert_to
      >>> convert_to(mile, kilometer)
      25146*kilometer/15625
      >>> convert_to(mile, kilometer).n()
      1.609344*kilometer
      >>> convert_to(speed_of_light, meter/second)
      299792458*meter/second
      >>> convert_to(day, second)
      86400*second
      >>> 3*newton
      3*newton
      >>> convert_to(3*newton, kilogram*meter/second**2)
      3*kilogram*meter/second**2
      >>> convert_to(atomic_mass_constant, gram)
      1.660539060e-24*gram
  
      Conversion to multiple units:
  
      >>> convert_to(speed_of_light, [meter, second])
      299792458*meter/second
      >>> convert_to(3*newton, [centimeter, gram, second])
      300000*centimeter*gram/second**2
  
      Conversion to Planck units:
  
      >>> convert_to(atomic_mass_constant, [gravitational_constant, speed_of_light, hbar]).n()
      7.62963087839509e-20*hbar**0.5*speed_of_light**0.5/gravitational_constant**0.5
  
      """
      from sympy.physics.units import UnitSystem
  
      unit_system = UnitSystem.get_unit_system(unit_system)
  
      if not isinstance(target_units, (Iterable, Tuple)):
          target_units = [target_units]
  
      if isinstance(expr, Add):
          return Add.fromiter(
              convert_to(i, target_units, unit_system)
              for i in expr.args
          )
  
      expr = sympify(expr)
      target_units = sympify(target_units)
  
      if not isinstance(expr, Quantity) and expr.has(Quantity):
          expr = expr.replace(
              lambda x: isinstance(x, Quantity),
              lambda x: x.convert_to(target_units, unit_system),
          )
  
      def get_total_scale_factor(expr):
          if isinstance(expr, Mul):
              return reduce(
                  lambda x, y: x * y,
                  [get_total_scale_factor(i) for i in expr.args],
              )
          elif isinstance(expr, Pow):
              return get_total_scale_factor(expr.base) ** expr.exp
          elif isinstance(expr, Quantity):
              return unit_system.get_quantity_scale_factor(expr)
          return expr
  
      depmat = _get_conversion_matrix_for_expr(
          expr, target_units, unit_system
      )
      if depmat is None:
          return expr
  
      expr_scale_factor = get_total_scale_factor(expr)
      return expr_scale_factor * Mul.fromiter(
          (1 / get_total_scale_factor(u) * u) ** p
          for u, p in zip(target_units, depmat)
      )
  
file_path: sympy/sympy/physics/units/util.py
imports: from functools import reduce
  from collections.abc import Iterable
  from typing import Optional
  from sympy import default_sort_key
  from sympy.core.add import Add
  from sympy.core.containers import Tuple
  from sympy.core.mul import Mul
  from sympy.core.power import Pow
  from sympy.core.sorting import ordered
  from sympy.core.sympify import sympify
  from sympy.matrices.exceptions import NonInvertibleMatrixError
  from sympy.physics.units.dimensions import Dimension, DimensionSystem
  from sympy.physics.units.prefixes import Prefix
  from sympy.physics.units.quantities import Quantity
  from sympy.physics.units.unitsystem import UnitSystem
  from sympy.utilities.iterables import sift
label_desc: Use image node_id 2 for calling a global function with example usage: convert_to(expr, target_units, unit_system) and returns: unknown, Add, expr, expr, reduce, unknown, unit_system