def METHOD_NAME(spark, log):
    indexer = JoinBasedIndexerEstimator().fit(log)
    indexed_df = indexer.transform(log)
    # inverse indexing
    df_with_primary_indexes = indexer.inverse_transform(indexed_df)
    # check that the number of rows remains the same
    assert indexed_df.count() == df_with_primary_indexes.count()
    # check the inverse indexing for users
    expected_unique_user_ids = (
        log.select("user_id").distinct().sort("user_id").collect()
    )
    actual_unique_user_ids = (
        df_with_primary_indexes.select("user_id")
        .distinct()
        .sort("user_id")
        .collect()
    )
    assert expected_unique_user_ids == actual_unique_user_ids
    # check the inverse indexing for items
    expected_unique_item_ids = (
        log.select("item_id").distinct().sort("item_id").collect()
    )
    actual_unique_item_ids = (
        df_with_primary_indexes.select("item_id")
        .distinct()
        .sort("item_id")
        .collect()
    )
    assert expected_unique_item_ids == actual_unique_item_ids