#nvidia-smi

IMAGENET_FOLDER="$platform_base_dir/datasets/ImageNet"
SPEC=IDC


run_experiment() {
    local ipc_val=${1}
    local preprocess_flag=${2}
    local postprocess_flag=${3}
    local run_step1=${4:-true}
    local run_step2=${5:-true}
    local run_step3=${6:-true}
    local soft_epochs=${7}

    local size_min=${8}
    local min_samples=${9}
    local n_neighbors=${10}

    local n=${11}

    local calcu_cluster_flag=${13:-false}
    local cluster_args=""
    if [[ "$calcu_cluster_flag" == "true" ]]; then
        cluster_args="--calcu_cluster"
    fi

    local i=0

    process_prefix="ori"
    local base_path_common="$platform_base_dir/MGresults/${process_prefix}/$SPEC"

    local base_path="${base_path_common}/SDXL_Refiner-step-$timestep/IPC-$ipc_val/DF-$DF-GTP-$GTP-DS-$mode_DS/min_samples-$min_samples/SizeMin-$size_min-n_neighbors-$n_neighbors-k-$k"

    local output_dataset="$base_path-n$n"
    local train_save_dir="${base_path_common}trained_results/ipc$ipc_val/$(basename "$base_path")/step-$timestep-DF-$DF/GS-$GS-GTP-$GTP-DS-$mode_DS"

    mkdir -p "$output_dataset"
    mkdir -p "$train_save_dir"
    local use_real_images=${12:-true}
    if [[ "$run_step2" == "true" ]]; then

        local train_data_path="$output_dataset/dataset_0"
        if [[ "$use_real_images" == "true" ]]; then
            train_data_path+="/real_images"
        fi
        python train.py -d imagenet --imagenet_dir "$train_data_path" "$IMAGENET_FOLDER" \
            -n resnet_ap --nclass 10 --norm_type instance --ipc "$ipc_val" --tag test --slct_type random --spec "$SPEC" --repeat 1 \
            --save-dir "$train_save_dir-resnet_ap-$n" --depth 10 --size 256 \
            --n_neighbors "$n_neighbors" --min_cluster_size "$size_min" \
            --workers 12 \
            --i_new $i

}

export CUDA_VISIBLE_DEVICES=0,1,2,
echo "==> 🚀  timestep: $timestep, $SPEC, IPC=$ipc, mode_DS=$mode_DS, DF=$DF, GTP=$GTP"
#               IPC      Pre    Post   Step1   Step2   Step3   soft_epochs  size_min        min_samples      n_neighbors  use_real_images    calcu_cluster_flag
run_experiment "$ipc"    false  false  true    false    false    300          "$size_min"  "$min_samples"   "$n_neighbors"  "$n"    "false"  "false"

# scripts/IDC.sh

# set-option -g history-limit 50000
