def METHOD_NAME(uri, rel):
    """
    According to xhtml2pdf documentation (see :doc:`xhtml2pdf:usage`),
    this function is necessary for resolving the django static files references.
    It returns the absolute paths to the files on the file system.
    :param uri: URI that is generated by django template tag 'static'
    :type uri: str
    :param rel: The relative path directory
    :type rel: str
    :return: The absolute path on the file system according to django's static file settings
    :rtype: str
    """
    parsed_uri = urlparse(uri)
    # When the uri is an absolute URL to an allowed host, convert it to an absolute local path
    if parsed_uri.hostname in settings.ALLOWED_HOSTS:
        uri = parsed_uri.path
        # When the url contains the legacy media url, replace it with the new pattern
        if (LEGACY_MEDIA_URL := "/wp-content/uploads/sites/") in uri:
            uri = f"/media/regions/{uri.partition(LEGACY_MEDIA_URL)[2]}"
    if uri.startswith(settings.MEDIA_URL):
        # Get absolute path for media files
        path = unquote(
            os.path.join(settings.MEDIA_ROOT, uri.replace(settings.MEDIA_URL, ""))
        )
        # make sure that file exists
        if not os.path.isfile(path):
            logger.exception(
                "The file %r was not found in the media directories.", path[:1024]
            )
            return None
        return path
    if uri.startswith(settings.STATIC_URL):
        # Remove the STATIC_URL from the start of the uri
        uri = uri[len(settings.STATIC_URL) :]
    elif uri.startswith("../"):
        # Remove ../ from the start of the uri
        uri = uri[3:]
    elif not uri.startswith("assets/"):
        logger.warning(
            "The file %r is not inside the static directories %r and %r.",
            uri[:1024],
            settings.STATIC_URL,
            settings.MEDIA_URL,
        )
        return uri
    if not (result := finders.find(uri)):
        logger.exception(
            "The file %r was not found in the static directories %r.",
            uri[:1024],
            finders.searched_locations,
        )
    return result