Tell me about how you would implement a robust API integration that handles rate limiting, retries, and error logging for a distributed system.
Implement process_api_requests using deterministic simulated responses. Enforce a shared fixed-window limit, retry 429 and transient 5xx responses, and record structured logs for failed attempts.
Input includes request IDs, response sequences, retry configuration, and rate-limit configuration. Return final request results and logs in the specified formats.
def process_api_requests(requests, max_retries, capacity, window):