<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def strip_namespaces(file_or_xml):
 """ Removes all namespaces from the XML file or string passed in. If file_or_xml is not a file or string, it is returned as is. """


    xml_content = _xml_content_to_string(file_or_xml)
    if not isinstance(xml_content, string_types):
        return xml_content

    # This pattern can have overlapping matches, necessitating the loop
    while _NAMESPACES_FROM_DEC_REGEX.search(xml_content) is not None:
        xml_content = _NAMESPACES_FROM_DEC_REGEX.sub(r'\1', xml_content)

    # Remove namespaces at the tag level
    xml_content = _NAMESPACES_FROM_TAG_REGEX.sub(r'\1', xml_content)

    # Remove namespaces at the attribute level
    xml_content = _NAMESPACES_FROM_ATTR_REGEX.sub(r'\1\3', xml_content)

    return xml_content