<commit_before>using DualNumbers

function autodiff(f, x, gradient_output, dualvec)
    # Assume f doesn't modify the input
    # otherwise we need to make a copy
    for i in 1:length(x)
        dualvec[i] = Dual(x[i], zero(x[i]))
    end
    for i in 1:length(x)
        dualvec[i] = Dual(real(dualvec[i]),one(eltype(x)))
        result = f(dualvec)
        gradient_output[i] = epsilon(result)
        dualvec[i] = Dual(real(dualvec[i])) # zero out derivative indicator
    end
<commit_msg>Style changes to autodiff code<commit_after>using DualNumbers

function autodiff{T <: Real}(f,
                             x::Vector{T},
                             gradient_output,
                             dualvec)
    # Assume f doesn't modify the input
    # otherwise we need to make a copy
    for i in 1:length(x)
        dualvec[i] = Dual(x[i], zero(T))
    end
    for i in 1:length(x)
        dualvec[i] = Dual(real(dualvec[i]), one(T))
        result = f(dualvec)
        gradient_output[i] = epsilon(result)
        dualvec[i] = Dual(real(dualvec[i]), zero(T))
    end

{'fraction_non_alphanumeric': 0.11862835959221502, 'fraction_numerical': 0.0037071362372567192, 'mean_word_length': 2.302752293577982, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5238120', 'n_tokens_mistral': 375, 'n_tokens_neox': 352, 'n_words': 93}