code: def _fix_fracs(string: str) -> str:
      """Source: https://github.com/hendrycks/math
      Reformat fractions.
      Examples:
      >>> _fix_fracs("\\frac1b")
      \frac{1}{b}
      >>> _fix_fracs("\\frac12")
      \frac{1}{2}
      >>> _fix_fracs("\\frac1{72}")
      \frac{1}{72}
      """
      substrs = string.split("\\frac")
      new_str = substrs[0]
      if len(substrs) > 1:
          substrs = substrs[1:]
          for substr in substrs:
              new_str += "\\frac"
              if substr[0] == "{":
                  new_str += substr
              else:
                  try:
                      if not len(substr) >= 2:
                          raise AssertionError
                  except Exception:
                      return string
                  a = substr[0]
                  b = substr[1]
                  if b != "{":
                      if len(substr) > 2:
                          post_substr = substr[2:]
                          new_str += (
                              "{" + a + "}{" + b + "}" + post_substr
                          )
                      else:
                          new_str += "{" + a + "}{" + b + "}"
                  else:
                      if len(substr) > 2:
                          post_substr = substr[2:]
                          new_str += "{" + a + "}" + b + post_substr
                      else:
                          new_str += "{" + a + "}" + b
      string = new_str
      return string
  
file_path: autogen/autogen/math_utils.py
imports: from typing import Optional
  from autogen import oai, DEFAULT_MODEL
label_desc: Use image node_id 4 for calling a global function with example usage: _fix_fracs(string) and returns: string, string