<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _create_dynamic_xml(self, cmdname, tag_name, mode, subelements=None):
 """Create RIBCL XML to send to iLO. This function creates the dynamic xml required to be sent to the ILO for all the APIs. :param cmdname: the API which needs to be implemented. :param tag_name: the tag info under which ILO has defined the particular API. :param mode: 'read' or 'write' :param subelements: dictionary containing subelements of the particular API tree. :returns: the etree.Element for the root of the RIBCL XML """

        root = etree.Element('RIBCL', VERSION="2.0")
        login = etree.SubElement(
            root, 'LOGIN', USER_LOGIN=self.login, PASSWORD=self.password)
        tagname = etree.SubElement(login, tag_name, MODE=mode)
        subelements = subelements or {}

        etree.SubElement(tagname, cmdname)

        if six.PY2:
            root_iterator = root.getiterator(cmdname)
        else:
            root_iterator = root.iter(cmdname)

        for cmd in root_iterator:
            for key, value in subelements.items():
                cmd.set(key, value)

        return root