def download_activitynet_split(
    dataset_dir,
    split,
    source_dir=None,
    classes=None,
    max_duration=None,
    copy_files=True,
    num_workers=None,
    shuffle=None,
    seed=None,
    max_samples=None,
    version="200",
):
    """Utility that downloads full or partial splits of the
    `ActivityNet dataset <http://activity-net.org/index.html>`_.

    Args:
        dataset_dir: the directory to download the dataset
        split: the split to download. Supported values are
            ``("train", "validation", "test")``
        source_dir (None): the directory containing the manually downloaded
            ActivityNet files
        classes (None): a string or list of strings specifying required classes
            to load. If provided, only samples containing at least one instance
            of a specified class will be loaded
        max_duration (None): only videos with a duration in seconds that is
            less than or equal to the ``max_duration`` will be downloaded. By
            default, all videos are downloaded
        copy_files (True): whether to move (False) or create copies (True) of
            the source files when populating ``dataset_dir``. This is only
            relevant when a ``source_dir`` is provided
        num_workers (None): a suggested number of threads to use when
            downloading individual videos
        shuffle (False): whether to randomly shuffle the order in which samples
            are chosen for partial downloads
        seed (None): a random seed to use when shuffling
        max_samples (None): a maximum number of samples to load per split. If
            ``classes`` are also specified, only up to the number of samples
            that contain at least one specified class will be loaded. By
            default, all matching samples are loaded
        version ("200"): the ActivityNet dataset version to download. The
            supported values are ``("100", "200")``

    Returns:
        a tuple of:

        -   **num_samples**: the total number of downloaded videos, or ``None``
            if everything was already downloaded
        -   **classes**: the list of all classes, or ``None`` if everything was
            already downloaded
        -   **did_download**: whether any content was downloaded (True) or if
            all necessary files were already downloaded (False)
    """
    manager = ActivityNetDatasetManager.from_dataset_dir(dataset_dir, version)

    if source_dir:
        manager.process_source(source_dir, copy_files)

    download_config = ActivityNetDownloadConfig(
        split,
        source_dir=source_dir,
        classes=classes,
        max_duration=max_duration,
        copy_files=copy_files,
        num_workers=num_workers,
        shuffle=shuffle,
        seed=seed,
        max_samples=max_samples,
    )

    all_classes = manager.all_classes
    num_existing = len(manager.existing_split_sample_ids(split))

    if download_config.load_entire_split:
        num_total = _NUM_TOTAL_SAMPLES[version][split]
        if num_existing != num_total:
            raise ValueError(
                "Found %d samples out of %d for split `%s`. In order to load "
                "a full ActivityNet split, you must download the source files "
                "from the ActivityNet maintainers. See "
                "https://docs.voxel51.com/integrations/activitynet.html#activitynet-full-split-downloads "
                "for more information."
                "\n\n"
                "Alternatively, provide the `max_samples`, `max_duration`, "
                "and/or `classes` parameters to download a subset of the "
                "dataset from YouTube." % (num_existing, num_total, split)
            )

        num_samples = num_existing
    else:
        (
            _,
            num_downloaded_samples,
        ) = manager.download_necessary_samples(download_config)
        num_samples = num_existing + num_downloaded_samples

    manager.write_data_json(split)

    return num_samples, all_classes
Utility that downloads full or partial splits of the
    `ActivityNet dataset <http://activity-net.org/index.html>`_.

    Args:
        dataset_dir: the directory to download the dataset
        split: the split to download. Supported values are
            ``("train", "validation", "test")``
        source_dir (None): the directory containing the manually downloaded
            ActivityNet files
        classes (None): a string or list of strings specifying required classes
            to load. If provided, only samples containing at least one instance
            of a specified class will be loaded
        max_duration (None): only videos with a duration in seconds that is
            less than or equal to the ``max_duration`` will be downloaded. By
            default, all videos are downloaded
        copy_files (True): whether to move (False) or create copies (True) of
            the source files when populating ``dataset_dir``. This is only
            relevant when a ``source_dir`` is provided
        num_workers (None): a suggested number of threads to use when
            downloading individual videos
        shuffle (False): whether to randomly shuffle the order in which samples
            are chosen for partial downloads
        seed (None): a random seed to use when shuffling
        max_samples (None): a maximum number of samples to load per split. If
            ``classes`` are also specified, only up to the number of samples
            that contain at least one specified class will be loaded. By
            default, all matching samples are loaded
        version ("200"): the ActivityNet dataset version to download. The
            supported values are ``("100", "200")``

    Returns:
        a tuple of:

        -   **num_samples**: the total number of downloaded videos, or ``None``
            if everything was already downloaded
        -   **classes**: the list of all classes, or ``None`` if everything was
            already downloaded
        -   **did_download**: whether any content was downloaded (True) or if
            all necessary files were already downloaded (False)
    
fiftyone/utils/activitynet.py