code: def _download_and_prepare(
      dataset_dir,
      scratch_dir,
      download_fcn,
      get_classes_fcn,
      sample_parser,
  ):
      # Download the torchvision dataset, if necessary
      dataset = download_fcn(scratch_dir)
  
      classes = get_classes_fcn(dataset)
      num_samples = len(dataset)
      sample_parser.classes = classes
      label_cls = sample_parser.label_cls
  
      if not isinstance(label_cls, (list, tuple)):
          label_cls = [label_cls]
  
      if fol.Classification in label_cls:
          dataset_type = fot.FiftyOneImageClassificationDataset()
          dataset_exporter = (
              foud.FiftyOneImageClassificationDatasetExporter(
                  dataset_dir, classes=classes
              )
          )
      elif fol.Detections in label_cls:
          dataset_type = fot.FiftyOneImageDetectionDataset()
          dataset_exporter = foud.FiftyOneImageDetectionDatasetExporter(
              dataset_dir, classes=classes
          )
      else:
          raise ValueError(
              "Unsupported sample parser %s" % type(sample_parser)
          )
  
      # Write the formatted dataset to `dataset_dir`
      foud.write_dataset(
          dataset,
          sample_parser,
          dataset_exporter,
          num_samples=num_samples,
      )
  
      return dataset_type, num_samples, classes
  
imports: import eta.core.utils
  import fiftyone.core.labels
  import fiftyone.core.utils
  import fiftyone.types
  import fiftyone.utils.coco
  import fiftyone.utils.data
  import fiftyone.utils.imagenet
  import fiftyone.utils.voc
  import fiftyone.zoo.datasets
label_desc: Use image node_id 1 for calling a global function with example usage: _download_and_prepare(dataset_dir, scratch_dir, download_fcn, get_classes_fcn, sample_parser) and returns: dataset_type,  num_samples,  classes