<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _bake_script(script):
 """ Takes a script element and bakes it in only if it contains a remote resource """

    if "src" in script.attrs:
        if re.match("https?://", script["src"]):
            script_data = _load_url(script["src"]).read()
        else:
            script_data = _load_file(script["src"]).read()
        script.clear()
        if USING_PYTHON2:
            script.string = "\n" + script_data + "\n"
        else:
            script.string = "\n" + str(script_data) + "\n"
        del script["src"]
        del script["type"]