For the final Exercise, I did this but I am not able to understand the error, due to which I am not able to complete the last part

for (minibatch_X, minibatch_Y) in zip(X_train, Y_train):

# Select a minibatch

with tf.GradientTape() as tape:

# 1. predict

Z3 = forward_propagation(minibatch_X, parameters)

# 2. loss

minibatch_cost = compute_cost(Z3, minibatch_Y)

```
trainable_variables = [W1, b1, W2, b2, W3, b3]
grads = tape.gradient(minibatch_cost, trainable_variables)
optimizer.apply_gradients(zip(grads, trainable_variables))
epoch_cost += minibatch_cost / minibatch_size
```

If someone can help me with it, it can be very helpful.

Thank you