The error points to a single value in grads['dl/df2'], while you are trying to index at position 5.
Your code seems to use some higher-level wrappers and other undefined functions, so that we would need a small executable code snippet to help debugging.