<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _expand_autotag(atag, container):
 """Expands the contents of the specified auto tag within its parent container. """

    if atag.tag != "auto":
        return

    if "names" in atag.attrib:
        i = -1
        for name in re.split("[\s,]+", atag.attrib["names"]):
            if name[0] == '^':
                name = name[1::]
                insert = True
                i += 1
            else:
                insert = False
                
            for child in atag:
                dupe = child.copy()
                for attr, value in dupe.items():
                    dupe.attrib[attr] = value.replace("$", name)

                if insert:
                    container.insert(i, dupe)
                else:
                    container.append(dupe)            
    else:
        from fortpy.msg import warn
        warn("'names' is a required attribute of the <auto> tag.")