# Package and read an image–caption dataset Build an offline Python standard-library workflow. Read top-level files in `data/dataset/` with six-digit sample keys and `.jpg` or `.txt` extensions. A key with both is a complete pair. Preserve the supplied inputs, including valid JPEGs. ## Outputs - `python3 solve.py` generates `shards/dataset-000000.tar`, `shards/dataset-000001.tar`, and so on, and `score.txt`. - `python3 dataloader_demo.py --batch-size B` prints one JSON array of sample keys per line, with positive batch size `B`. - `python3 distributed_demo.py --rank R --world-size N` prints one sample key per line and no other stdout. Use positive `N` and a zero-based rank `0 <= R < N`. Local Python helpers are allowed; do not require additional packages or network access. ## Acceptance Checklist - Discover complete pairs from the current inputs and skip incomplete pairs. Sort the keys lexicographically and put consecutive groups of six in contiguous zero-based shards; the last group may be shorter. Remove stale `dataset-*.tar` outputs. - Each archive contains only the original bytes and filenames of the two files for each assigned key, with no duplicates. Ordering of members within the tar is unrestricted. - `score.txt` contains `x/y`, where `x` counts complete pairs and `y` counts keys with either extension. Shards and score reflect input changes rather than fixed fixture counts. - With only the shards available, the batch reader emits all keys in global sorted order, with a final short batch when needed. - With only the shards available, each distributed rank emits sorted keys whose **global sample index** modulo `N` is `R`. Outputs are disjoint and collectively complete; a single rank reads everything and an empty rank prints nothing.