Tell me about the PySpark fundamentals you rely on when building data pipelines.
Implement those fundamentals by filtering invalid records, keeping the highest-version record for each event, aggregating by entity, and sorting the result.
Input is a list of dictionaries. Return dictionaries containing entity, event_count, and total_amount.
def summarize_records(records):