code: def _select_task_labels(
      dataset: Any, indices: Optional[List[int]]
  ) -> Optional[Sequence[SupportsInt]]:
      """
      Selector function to be passed to :func:`_traverse_supported_dataset`
      to obtain the `targets_task_labels` for the given dataset.
  
      :param dataset: the traversed dataset.
      :param indices: the indices describing the subset to consider.
      :returns: The list of task labels or None if not found.
      """
      found_task_labels: Optional[Sequence[SupportsInt]] = None
      if hasattr(dataset, "targets_task_labels"):
          found_task_labels = dataset.targets_task_labels
  
      if found_task_labels is None:
          if isinstance(dataset, (Subset, ConcatDataset)):
              return None  # Continue traversing
  
      if found_task_labels is None:
          if indices is None:
              return ConstantSequence(0, len(dataset))
          return ConstantSequence(0, len(indices))
  
      if indices is not None:
          found_task_labels = SubSequence(
              found_task_labels, indices=indices
          )
  
      return found_task_labels
  
imports: from collections import OrderedDict, defaultdict, deque
  from typing import TYPE_CHECKING, Any, Callable, Generic, Iterator, List, Iterable, Mapping, Optional, Sequence, TypeVar, Union, Dict, SupportsInt
  import warnings
  import torch
  from torch import Tensor
  from torch.utils.data import Subset, ConcatDataset
  from .data import AvalancheDataset
  from .data_attribute import DataAttribute
  from .dataset_definitions import ISupportedClassificationDataset
  from .dataset_utils import SubSequence, find_list_from_index
  from .flat_data import ConstantSequence
  from .transform_groups import TransformGroupDef, TransformGroups, XTransform, YTransform
label_desc: Use image node_id 12 for calling a global function with example usage: _select_task_labels(dataset, indices) and returns: found_task_labels, ConstantSequence, None, ConstantSequence