Atlas: Learning to Optimally Memorize the Context at Test Time