To this Julia code:
addprocs()
@everywhere using DataFrames

# Load Data
data = CSV.read("C:/Users/Użytkownik/Desktop/player22.csv", DataFrame)

(position -> global _position; @eval begin
             (_position)_idx = findall(occursin.(
(_position), data.Positions))
         end)(position) for position in ["RW", "ST", "GK", "CM", "LW", "CDM", "LM", "CF", "CB", "CAM", "LB", "RB", "RM", "LWB", "RWB"])

position_vectors = [RW_idx, ST_idx, GK_idx, CM_idx, LW_idx,
                    CDM_idx, LM_idx, CF_idx, CB_idx, CAM_idx,
                    LB_idx ,RB_idx, RM_idx, LWB_idx, RWB_idx]

# Mutation 2
@everywhere function mutate(selected_players_df, position_vectors, probability)
    n_rows, _ = size(selected_players_df)
    selected_players_matrix = selected_players_df
    
    function select_random_player(idx_list, selected_players)
        while true
            random_idx = rand(idx_list)
            (in(random_idx, selected_players)) || return(random_idx)
        end
    end

    for i in 1:n_rows
        for (pos_idx, index_vector) in enumerate(position_vectors)
            if rand() <= probability
                idx = select_random_player(index_vector, Set(selected_players_matrix[i, :]))
                selected_players_matrix[i, pos_idx] = idx
            end
        end
    end

    selected_players_df = DataFrame(selected_players_matrix)
    return selected_players_df
end

n_rows = 100
pop_init = DataFrame(Matrix{Union{Missing,Int}}(missing, n_rows, length(position_vectors)))
pop_init = mutate(pop_init, position_vectors, probability=1)

# Target
row1 = pop_init[1, :]

@everywhere using DataFrames
@everywhere target(row1; penalty=5) = 
begin
    position_ratings = ["RWRating", "STRating", "GKRating", "CMRating",
                       "LWRating", "CDMRating", "LMRating", "CFRating",
                       "CBRating", "CAMRating", "LBRating", "RBRating",
                       "RMRating", "LWBRating", "RWBRating"]

    parent_data = data[vec(row1), :]
    ratings = Vector{Int}(parent_data[position_ratings]);    
    ratings_log = log.(ratings)

    potential_minus_age = 0.15 .* parent_data.Potential - 0.6 .* parent_data.Age
    int_reputation = parent_data.IntReputation

    rating_list = diagonals(ratings_log)

    constraint_penalty = summary_stats = 0
    function apply_constraints()
        if sum(parent_data.ValueEUR) > 250000000
            summary_stats += log((sum(parent_data.ValueEUR)-250000000)^penalty)
        end
        if sum(parent_data.WageEUR) > 250000
            summary_stats += log((sum(parent_data.WageEUR)-250000)^penalty)
        end
        if any(rating_list < 1.2)
            summary_stats += 1.2^penalty
        end
        return summary_stats
    end
    apply_constraints()

    target_value = -((sum(ratings_log)+0.3*sum(potential_minus_age)) + sum(int_reputation) + constraint_penalty)

    target_value
end

# Tournament Selection
parents = pop_init
t_size = 2
penalty = 1

function tournament_selection(parents, t_size; penalty=6)
    n = nrow(parents)
    random_parents_idx = sample(1:n, t_size, replace = false)
    random_parents = parents[random_parents_idx, :]

    random_parents_fitness = [target(row, penalty=penalty) for row in eachrow(random_parents)]

    best_parent_idx = argmin(random_parents_fitness)
    random_parents[best_parent_idx, :]
end

tournament_selection(pop_init,t_size=2)

crossover_point = 6

function crossover(parent1, parent2, crossover_point)
    offspring1 = vcat(parent1[1:crossover_point], parent2[(crossover_point + 1):end])
    offspring2 = vcat(parent2[1:crossover_point], parent1[(crossover_point + 1):end])
    return [offspring1 offspring2]
end

function run_ga(num_generations)
    crossover_point = 7
    population_size = 100
    tournament_size = 2
    probability = 0.09
    penalty = 1
    parents = pop_init

    global_best = pop_init[1, :]
    global_best_value = target(global_best)

    for gen in 1:num_generations
        parent_pop = DataFrame(Matrix{Int}(undef, population_size, length(position_vectors)))

        for c in 1:population_size
            parent_pop[c, :] .= tournament_selection(parents, t_size=tournament_size, penalty=penalty)
        end

        offspring_temp = DataFrame(Matrix{Int}(undef, 1, length(position_vectors)))

        for c in 1:2:population_size
            parent1 = parent_pop[c, :]
            parent2 = parent_pop[c + 1, :]

            offsprings = crossover(parent1, parent2, crossover_point)
            o1 = offsprings[:, 1]
            o2 = offsprings[:, 2]

            push!(offspring_temp, o1)
            push!(offspring_temp, o2)
        end

        delete!(offspring_temp, 1)
        parents = mutate(offspring_temp, position_vectors, probability=probability)

        solutions = [target(row) for row in eachrow(parents)]
        idx_sol = argmin(solutions)
        temp_best = parents[idx_sol, :]
        temp_target_value = solutions[idx_sol]

        if temp_target_value <= global_best_value
            global_best = temp_best
            global_best_value = temp_target_value
        end

        penalty += 0.5
        if penalty >= 4
            penalty = 0
        end
    end

    global_best_fin = convert(Matrix, global_best')
    parent_data = data[vec(global_best_fin), :]
    target_value = target(global_best)

    result = (generations = num_generations, target_value = target_value)
    return result
end

num_generations_range = 1000:5000:50000

global_results = SharedArray{NamedTuple}(1, length(num_generations_range))

@sync @distributed for i in 1:length(num_generations_range)
    num_generations = num_generations_range[i]
    println("Current Generation: $num_generations")
    result = run_ga(num_generations)
    global_results[i] = result
    println("Generations: ", result.generations, ", target_value: ", result.target_value)
end

results_df = DataFrame(global_results)
println(results_df)

I get this error:
syntax: extra token "for" after end of expression

Stacktrace:
 [1] top-level scope
   @ In[7]:12

And honestly, I actually only want to use @sync @distributed for this loop:
@sync @distributed for i in 1:length(num_generations_range)
    num_generations = num_generations_range[i]
    println("Current Generation: $num_generations")
    result = run_ga(num_generations)
    global_results[i] = result
    println("Generations: ", result.generations, ", target_value: ", result.target_value)
end
Everything else can be skipped.