<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def label_to_latex(text):
 # pylint: disable=anomalous-backslash-in-string r"""Convert text into a latex-passable representation. This method just escapes the following reserved LaTeX characters: % \ _ ~ &, whilst trying to avoid doubly-escaping already escaped characters Parameters text : `str` input text to convert Returns ------- tex : `str` a modified version of the input text with all unescaped reserved latex characters escaped Examples -------- 'normal text' '$1 + 2 = 3$' 'H1:ABC-DEF\\_GHI' 'H1:ABC-DEF\\_GHI' """

    if text is None:
        return ''
    out = []
    x = None
    # loop over matches in reverse order and replace
    for m in re_latex_control.finditer(text):
        a, b = m.span()
        char = m.group()[0]
        out.append(text[x:a])
        out.append(r'\%s' % char)
        x = b
    if not x:  # no match
        return text
    # append prefix and return joined components
    out.append(text[b:])
    return ''.join(out)