code: def _make_image_labels_dataset(
      img, images_dir, num_samples=4, num_objects_per_sample=3
  ):
      exts = [".jpg", ".png"]
  
      samples = []
      for idx in range(num_samples):
          filepath = os.path.join(
              images_dir, "%06d%s" % (idx, exts[idx % len(exts)])
          )
          foui.write(img, filepath)
  
          sample = fo.Sample(filepath=filepath)
  
          label = random.choice(["sun", "rain", "snow"])
          sample["gt_weather"] = fo.Classification(label=label)
  
          detections = []
          for _ in range(num_objects_per_sample):
              label = random.choice(["cat", "dog", "bird", "rabbit"])
              bounding_box = [
                  0.8 * random.random(),
                  0.8 * random.random(),
                  0.2,
                  0.2,
              ]
              detections.append(
                  fo.Detection(label=label, bounding_box=bounding_box)
              )
  
          sample["gt_objects"] = fo.Detections(detections=detections)
  
          samples.append(sample)
  
      dataset = fo.Dataset()
      dataset.add_samples(samples)
      return dataset
  
imports: import random
  import os
  import numpy
  import pytest
  import eta.core.utils
  import fiftyone
  import fiftyone.utils.image
  import fiftyone.brain
  import fiftyone.zoo
  from fiftyone import ViewField
label_desc: Use image node_id 6 for calling a global function with example usage: _make_image_labels_dataset(img, images_dir, num_samples, num_objects_per_sample) and returns: dataset