def batch_cmd_create_dl3(
        dl2_file,
        dl3_dir,
        run,
        source_name,
        source_ra,
        source_dec,
        irf,
        dl3_config,
        job_irf
):
    """Create batch command to create DL3 files with sbatch."""
    log_dir = dl3_dir / "log"
    log_dir.mkdir(exist_ok=True, parents=True)
    log_file = log_dir / f"dl2_to_dl3_Run{run:05d}_{source_name}_%j.log"
    sbatch_cmd = [
        "sbatch",
        "--mem=10GB",
        "--job-name=dl2dl3",
        "-D",
        dl3_dir,
        "-o",
        log_file,
        "--parsable",
    ]
    if job_irf is not None:
        sbatch_cmd.append(f"--dependency=afterok:{job_irf}")

    dl3_cmd = [
        "lstchain_create_dl3_file",
        f"-d={dl2_file}",
        f"-o={dl3_dir}",
        f"--input-irf={irf}",
        f"--source-name={source_name}",
        f"--source-ra={source_ra}deg",
        f"--source-dec={source_dec}deg",
        "--overwrite",
    ]
    if dl3_config:
        dl3_cmd.append(f"--config={dl3_config}")

    return sbatch_cmd + dl3_cmd