A Unified Framework for Inference with General Missingness Patterns and Machine Learning Imputation