Understanding AI Cognition: A Neural Module for Inference Inspired by Human Memory Mechanisms