class_docstr: A simple Monomial class to
  record the details of all variables
  that a typical monomial is composed of.
class_docstr_tok: ["A","simple","Monomial","class","to","record","the","details","of","all","variables","that","a","typical","monomial","is","composed","of","."]
docstr: Substitute the variables in the
  monomial for values defined by
  the substitutions dictionary.
docstr_tok: ["Substitute","the","variables","in","the","monomial","for","values","defined","by","the","substitutions","dictionary","."]
code: def substitute(
      self,
      substitutions: Union[
          int, float, Fraction, Dict[int, Union[int, float, Fraction]]
      ],
  ) -> Fraction:
      """
      Substitute the variables in the
      monomial for values defined by
      the substitutions dictionary.
      """
      if (
          isinstance(substitutions, int)
          or isinstance(substitutions, float)
          or isinstance(substitutions, Fraction)
      ):
          substitutions = {
              v: Monomial._rationalize_if_possible(substitutions)
              for v in self.all_variables()
          }
      else:
          if not self.all_variables().issubset(
              set(substitutions.keys())
          ):
              raise ValueError(
                  "Some variables didn't receive their values."
              )
      if self.coeff == 0:
          return Fraction(0, 1)
      ans = Monomial._rationalize_if_possible(self.coeff)
      for k in self.variables:
          ans *= Monomial._rationalize_if_possible(
              substitutions[k] ** self.variables[k]
          )
      return Monomial._rationalize_if_possible(ans)
  
imports: from fractions import Fraction
  from typing import Dict, Union, Set, Iterable
  from numbers import Rational
  from functools import reduce
label_desc: Use image node_id 15 for calling the Monomial obj's underlying member method code with example usage: obj.substitute(substitutions) and returns: Monomial, Fraction