Using zygote for a summation derivation

Hi,
I am using zygote and rrule to define my derivation formulation. the derivative of my function is

df/dr = sum1st to Nth step(w^T * da/dr)

in order to solve this i have defined below code. Note that i saved all values of w,wg,ul,sl,vl in a matrix or vector.

function rrule(::typeof(gf_pf), pf_vec, vApp; β, η, fem_params)
    function U_Disp_pullback(dgdg)
      NO_FIELDS, dgdg * Dgfdpf(pf_vec,vApp; β, η, fem_params)
    end
    gf_pf(pf_vec,vApp; β, η, fem_params), U_Disp_pullback
end
function Dgfdpf(pf_vec,vApp; β, η, fem_params)
    pfh = FEFunction(fem_params.Pf, pf_vec)
    pth = (pf -> Threshold(pf; β, η)) ∘ pfh
    dgfdpf = zeros(sr)
    for i in 1:co
        u_vec = ul[:,i]
        sh_vec = sl[:,i]
        sh = FEFunction(fem_params.U_PF, sh_vec)
        vApp = vl[i]
        uAppp1(x) = VectorValue(0.0,0.0)
        uAppp2(x) = VectorValue(0.0,0.0)
        uAppp3(x) = VectorValue(0.0,-vApp)
        U_Disp = TrialFESpace(V0_Disp ,[uAppp1 ,uAppp2 ,uAppp3])
        uh = FEFunction(U_Disp, u_vec)
        wvec = w[:,i]
        wgvec = wg[:,i]
        wconjh = FEFunction(U_Disp, conj(wvec)) 
        wconjhg = FEFunction(fem_params.U_PF, conj(wgvec)) 
        l_temp(dp) = ∫( (-2*(DAdpf(wconjh,uh,pfh; β, η)) - DGdpf(wconjhg,sh,pfh; β, η) )*dp )fem_params.dΩ
        dgfdpf_temp = assemble_vector(l_temp, fem_params.Pf)
        dgfdpf = dgfdpf_temp .+ dgfdpf
    end
    return dgfdpf
end

but this code is not running and zygote cant do this. could you please tell me how can i perform summation in zygote?
thank you