added multi layer gradient accumulation and averaging