Explain the chain rule in complex architectures and how you manually derive gradients for specific loss functions.