def METHOD_NAME(train: bool = True, n_samples: t.Optional[int] = None, transforms=None) -> tf.data.Dataset:
    """Create a tf dataset of the COCO128 dataset."""
    coco_dir, dataset_name = download_coco128(COCO_DIR)
    img_dir = Path(coco_dir / 'images' / dataset_name)
    label_dir = Path(coco_dir / 'labels' / dataset_name)
    files = os.listdir(img_dir)
    train_len = int(TRAIN_FRACTION * len(files))
    files = files[:train_len] if train else files[train_len:]
    if n_samples is not None and n_samples < len(files):
        files = files[:n_samples]
    images, labels = [], []
    for file_name in files:
        label_file = label_dir / str(file_name).replace('jpg', 'txt')
        image, label = get_image_and_label(img_dir / str(file_name), label_file, transforms)
        images.append(image)
        labels.append(np.asarray(label))
    def generator():
        for img, label in zip(images, labels):
            yield img, label
    dataset = tf.data.Dataset.from_generator(generator, output_signature=(
        tf.TensorSpec(shape=(None, None, 3)), tf.TensorSpec(shape=None)))
    return dataset