code: def create_tf_dataset(
      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
  
file_path: deepchecks/deepchecks/vision/datasets/detection/coco_tensorflow.py
imports: import os
  import typing
  from pathlib import Path
  import albumentations
  import numpy
  from typing_extensions import Literal
  from deepchecks import vision
  from deepchecks.vision.datasets.detection.coco_utils import COCO_DIR, LABEL_MAP, download_coco128, get_image_and_label
  from deepchecks.vision.vision_data import VisionData
label_desc: Use image node_id 4 for calling a global function with example usage: create_tf_dataset(train, n_samples, transforms) and returns: dataset