# How to calculate Vega using Dupire and MonteCarlo engine with Autograd?

I have implemented a Monte Carlo pricer engine which includes the volatility local model based on Dupire formula. For now I can value several (european) options which I used to validate the model, but the problem comes when I try to calculate the Vega greek with Autograd (AAD python package).

My inputs in the MC engine are the following ones : mc_value(option_type, S0, K, r, T, I, N, interpolator, q=0), where "interpolator" is the function I created (interpolating) based in the local volatility surface I got from Dupire.

What I am doing is to apply the function "grad" of Autograd to this function but the error message is that Autograd can't differentiate respect to a fucntion ("interpolator"), but I can calculate every other Greek in this way.

My question is if I am calculating Vega correctly (differentiating respect to the function of local vol). I have thought and searched a lot and I am pretty sure that the interpolator has to be an input in the Monte Carlo engine so I don't know how to carry on.

PD: The final goal is to calculate Vega with Autograd so finite differences is not an option.

Thanks