def METHOD_NAME(input_dict, encoding="utf-8", pretty=False):
    """Converts a python dictionary into a valid XML string
    Args:
        - encoding specifies the encoding to be included in the encoding
          segment. If set to False no encoding segment will be displayed.
        - customRoot defines the tag to wrap the returned output. Can be
          a string, dictionary, or False if no custom root is to be used.
    Returns:
        A XML formatted string representing the dictionary.
    Examples:
        ```
        dic = {
            "Envelope": {
                "@ns": "soapenv",
                "@attrs": {
                    "xmlns:soapenv": "http://schemas.xmlsoap.org/soap/envelope/",
                    "xmlns:urn": "urn:partner.soap.sforce.com"
                },
                "Header": {
                    "@ns": "soapenv",
                    "SessionHeader": {
                        "@ns": "urn",
                        "sessionId": {
                            "@ns": "urn",
                            "@value": "00D36000000b28L!ARsAQMtHo4XD71VYRxoz"
                        }
                    }
                },
                "Body": {
                    "@ns": "soapenv",
                    "query": {
                        "@ns": "urn",
                        "queryString": {
                            "@ns": "urn",
                            "@value": "SELECT Id, Name FROM Account LIMIT 2"
                        }
                    }
                }
            }
        }
        xml = xml2dict(dict, customRoot=False)
        print(xml)
        ```
        output:
        ```
        <?xml version="1.0" encoding="UTF-8"?>
        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
          xmlns:urn="urn:partner.soap.sforce.com">
          <soapenv:Header>
             <urn:SessionHeader>
                <urn:sessionId>{0}</urn:sessionId>
             </urn:SessionHeader>
          </soapenv:Header>
        </soapenv:Envelope>
        ```
    """
    xml_string = tostring(parse(input_dict, pretty=pretty), encoding=encoding)
    if pretty:
        xml_pretty_string = minidom.parseString(xml_string)
        return xml_pretty_string.toprettyxml().decode(encoding)
    else:
        return xml_string.decode(encoding)