code: def _as_taskaware_supervised_classification_dataset(
      dataset,
      *,
      transform: Optional[XTransform] = None,
      target_transform: Optional[YTransform] = None,
      transform_groups: Optional[
          Mapping[str, TransformGroupDef]
      ] = None,
      initial_transform_group: Optional[str] = None,
      task_labels: Optional[Union[int, Sequence[int]]] = None,
      targets: Optional[Sequence[TTargetType]] = None,
      collate_fn: Optional[Callable[[List], Any]] = None,
  ) -> TaskAwareSupervisedClassificationDataset:
      if (
          transform is not None
          or target_transform is not None
          or transform_groups is not None
          or initial_transform_group is not None
          or task_labels is not None
          or targets is not None
          or collate_fn is not None
          or not isinstance(
              dataset, TaskAwareSupervisedClassificationDataset
          )
      ):
          result_dataset = _make_taskaware_classification_dataset(
              dataset=dataset,
              transform=transform,
              target_transform=target_transform,
              transform_groups=transform_groups,
              initial_transform_group=initial_transform_group,
              task_labels=task_labels,
              targets=targets,
              collate_fn=collate_fn,
          )
  
          if not isinstance(
              result_dataset, TaskAwareSupervisedClassificationDataset
          ):
              raise ValueError(
                  "The given dataset does not have supervision fields "
                  "(targets, task_labels)."
              )
  
          return result_dataset
  
      return dataset
  
imports: from functools import partial
  import torch
  from torch.utils.data.dataset import Subset, ConcatDataset, TensorDataset
  from avalanche.benchmarks.utils.utils import TaskSet, _count_unique, find_common_transforms_group, _init_task_labels, _init_transform_groups, _split_user_def_targets, _split_user_def_task_label, _traverse_supported_dataset
  from avalanche.benchmarks.utils.data import AvalancheDataset
  from avalanche.benchmarks.utils.transform_groups import TransformGroupDef, DefaultTransformGroups, XTransform, YTransform
  from avalanche.benchmarks.utils.data_attribute import DataAttribute
  from avalanche.benchmarks.utils.dataset_utils import SubSequence
  from avalanche.benchmarks.utils.flat_data import ConstantSequence
  from avalanche.benchmarks.utils.dataset_definitions import ISupportedClassificationDataset, ITensorDataset, IDatasetWithTargets
  from typing import List, Any, Sequence, Union, Optional, TypeVar, Callable, Dict, Tuple, Mapping, overload
label_desc: Use image node_id 20 for calling a global function with example usage: _as_taskaware_supervised_classification_dataset(dataset) and returns: dataset, result_dataset