Write a program to parse a large, nested JSON log file and extract specific nested fields while handling malformed records gracefully.
Implement extract_log_fields(lines, fields). lines is an array of JSON record strings. fields is a map from output field names to paths, where each path is an array of object keys or array indexes. Return one map per valid JSON object, containing every requested field. If a path is missing or encounters an incompatible value, use null. Skip malformed JSON lines and valid JSON values whose root is not an object.
def extract_log_fields(lines, fields):