def METHOD_NAME(
    relationships: List[Relationship], packages: List[Package], files: List[File]
) -> Tuple[List, Dict]:
    contained_files_by_package_id = dict()
    relationships_to_write = []
    files_by_spdx_id = {file.spdx_id: file for file in files}
    packages_spdx_ids = [package.spdx_id for package in packages]
    for relationship in relationships:
        if (
            relationship.relationship_type == RelationshipType.CONTAINS
            and relationship.spdx_element_id in packages_spdx_ids
            and relationship.related_spdx_element_id in files_by_spdx_id.keys()
        ):
            contained_files_by_package_id.setdefault(relationship.spdx_element_id, []).append(
                files_by_spdx_id[relationship.related_spdx_element_id]
            )
            if relationship.comment:
                relationships_to_write.append(relationship)
        elif (
            relationship.relationship_type == RelationshipType.CONTAINED_BY
            and relationship.related_spdx_element_id in packages_spdx_ids
            and relationship.spdx_element_id in files_by_spdx_id
        ):
            contained_files_by_package_id.setdefault(relationship.related_spdx_element_id, []).append(
                files_by_spdx_id[relationship.spdx_element_id]
            )
            if relationship.comment:
                relationships_to_write.append(relationship)
        else:
            relationships_to_write.append(relationship)
    return relationships_to_write, contained_files_by_package_id