Understanding LLMs: A Comprehensive Overview from Training to Inference