def METHOD_NAME(profiles: Sequence[Profile]) -> dict:
    # Transform the profile data into a sequence of mappings:
    # contracts -> functions -> profiles.
    # defaultdict -> defaultdict -> dict.
    contracts: dict = collections.defaultdict(lambda: collections.defaultdict(dict))
    for profile in profiles:
        for contract, functions in profile.contracts.items():
            for function, gas in functions.items():
                contracts[contract][function][profile.filename] = gas
    return contracts