ATA: Adaptive Task Allocation for Efficient Resource Management in Distributed Machine Learning