code: def test_avalanche_dataset_mixed_task_labels(self):
      dataset_mnist = MNIST(
          root=default_dataset_location("mnist"), download=True
      )
      x, y = dataset_mnist[0]
  
      random_task_labels = [
          random.randint(0, 10) for _ in range(len(dataset_mnist))
      ]
      dataset = _make_taskaware_classification_dataset(
          dataset_mnist,
          transform=ToTensor(),
          task_labels=random_task_labels,
      )
      x2, y2, t2 = dataset[0]
  
      self.assertIsInstance(x2, Tensor)
      self.assertIsInstance(y2, int)
      self.assertIsInstance(t2, int)
      self.assertEqual(random_task_labels[0], t2)
      self.assertTrue(torch.equal(ToTensor()(x), x2))
      self.assertEqual(y, y2)
  
      self.assertListEqual(
          random_task_labels, list(dataset.targets_task_labels)
      )
  
      u_labels, counts = np.unique(
          random_task_labels, return_counts=True
      )
      for i, task_label in enumerate(u_labels.tolist()):
          subset_task = dataset.task_set[task_label]
          self.assertIsInstance(
              subset_task, TaskAwareClassificationDataset
          )
          self.assertEqual(int(counts[i]), len(subset_task))
  
          unique_task_labels = list(subset_task.targets_task_labels)
          self.assertListEqual(
              [task_label] * int(counts[i]), unique_task_labels
          )
  
      with self.assertRaises(KeyError):
          subset_task11 = dataset.task_set[11]
  
imports: import unittest
  from avalanche.benchmarks.datasets import default_dataset_location
  import PIL
  import torch
  from PIL import ImageChops
  from PIL.Image import Image
  from torch import Tensor
  from torch.utils.data import ConcatDataset, TensorDataset
  from torchvision.datasets import MNIST
  from torchvision.transforms import ToTensor, RandomCrop, CenterCrop
  from avalanche.benchmarks.utils import _make_taskaware_classification_dataset, make_avalanche_dataset
  from avalanche.benchmarks.utils.flat_data import ConstantSequence
  import random
  import numpy
  from avalanche.benchmarks.utils import DefaultTransformGroups
  from avalanche.benchmarks.utils.data_attribute import TaskLabels, DataAttribute
  from avalanche.benchmarks.utils.data import AvalancheDataset
  from avalanche.benchmarks.utils.flat_data import _flatdata_depth, _flatdata_print
  from avalanche.benchmarks.utils.classification_dataset import TaskAwareClassificationDataset, TaskAwareSupervisedClassificationDataset
  from tests.unit_tests_utils import dummy_image_dataset, dummy_tensor_dataset, load_image_data
label_desc: Use image node_id 15 for calling the AvalancheDatasetTests obj's underlying member method code with example usage: obj.test_avalanche_dataset_mixed_task_labels() without return types