<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_docs(self, string, container = None):
 """Parses the docstrings from the specified string that is the contents of container. Returns a dictionary with keys as parent.code_element_name and the values a list of XML elements for corresponding docstrings. :arg container: the instance of the element who owns the string. """

        from fortpy.utility import XML
        result = {}
        if container is None:
            #We are working with the code file at the module level. Extract the module
            #docstrings and XML and return the dictionary with module names as keys.
            for module in self.RE_MODDOCS.finditer(string):
                docstring = re.sub("\s*!!", "", module.group("docstring"))
                doctext = "<doc>{}</doc>".format(re.sub("\n", "\s", docstring))
                try:
                    docs = XML(doctext)
                    #Get the name of the module to use as the key and then add the list
                    #of XML docstrings to the result.
                    key = module.group("name")
                    if not key in result:
                        result[key] = [list(docs), module.start(), module.end()]
                    else:
                        result[key][0].extend(list(docs))
                except ET.ParseError:
                    msg.err(doctext)
        else:
            #This is the text content of a code element that was buried inside of the module.
            #Get all the docblocks and the items they decorate from this parent.
            result = self._parse_docblocks(string, container)
            
        return result