docstr: This class is used to sample epoch_length tasks to represent an epoch.
  
  It should be used when using DataParallel
  
  Args:
      taskset: Dataset used to sample task.
      epoch_length: The expected epoch length. This requires to be divisible by devices.
      devices: Number of devices being used.
      collate_fn: The collate_fn to be applied on multiple tasks
docstr_tok: ["This","class","is","used","to","sample","epoch_length","tasks","to","represent","an","epoch",".","It","should","be","used","when","using","DataParallel","Args",":","taskset",":","Dataset","used","to","sample","task",".","epoch_length",":","The","expected","epoch","length",".","This","requires","to","be","divisible","by","devices",".","devices",":","Number","of","devices","being","used",".","collate_fn",":","The","collate_fn","to","be","applied","on","multiple","tasks"]
code: def __init__(
      self,
      tasks: Any,
      epoch_length: int,
      devices: int = 1,
      collate_fn: Optional[Callable] = default_collate,
  ):
      """This class is used to sample epoch_length tasks to represent an epoch.
  
      It should be used when using DataParallel
  
      Args:
          taskset: Dataset used to sample task.
          epoch_length: The expected epoch length. This requires to be divisible by devices.
          devices: Number of devices being used.
          collate_fn: The collate_fn to be applied on multiple tasks
  
      """
      self.tasks = tasks
      self.epoch_length = epoch_length
      self.devices = devices
  
      if epoch_length % devices != 0:
          raise Exception(
              "The `epoch_length` should be the number of `devices`."
          )
  
      self.collate_fn = collate_fn
      self.counter = 0
  
file_path: lightning-flash/src/flash/image/classification/integrations/learn2learn.py
imports: from typing import Any, Callable, Optional
  import pytorch_lightning
  from torch.utils.data import IterableDataset
  from torch.utils.data._utils.worker import get_worker_info
  from flash.core.data.utilities.collate import default_collate
  from flash.core.utilities.imports import requires
label_desc: Use image node_id 1 to create a new TaskDataParallel object from inherited base classes: IterableDataset with example: obj = TaskDataParallel(tasks, epoch_length, devices, collate_fn)