docstr: The List Object is used to represents list collection of :class:`~lightning.app.core.work.LightningWork` or
  :class:`~lightning.app.core.flow.LightningFlow`.
  
  Example:
  
      >>> from lightning.app import LightningFlow, LightningWork
      >>> from lightning.app.structures import List
      >>> class CounterWork(LightningWork):
      ...     def __init__(self):
      ...         super().__init__()
      ...         self.counter = 0
      ...     def run(self):
      ...         self.counter += 1
      ...
      >>> class RootFlow(LightningFlow):
      ...     def __init__(self):
      ...         super().__init__()
      ...         self.list = List(*[CounterWork(), CounterWork()])
      ...     def run(self):
      ...         for work in self.list:
      ...             work.run()
      ...
      >>> flow = RootFlow()
      >>> flow.run()
      >>> assert flow.list[0].counter == 1
  
  Arguments:
      items: A sequence of LightningWork or LightningFlow.
docstr_tok: ["The","List","Object","is","used","to","represents","list","collection","of",":","class",":","`","~lightning.app.core.work.LightningWork","`","or",":","class",":","`","~lightning.app.core.flow.LightningFlow","`",".","Example",":",">",">",">","from","lightning.app","import","LightningFlow",",","LightningWork",">",">",">","from","lightning.app.structures","import","List",">",">",">","class","CounterWork","(","LightningWork",")",":","...","def","__init__","(","self",")",":","...","super","(",")",".__init__","(",")","...","self.counter","=","0","...","def","run","(","self",")",":","...","self.counter","+=","1","...",">",">",">","class","RootFlow","(","LightningFlow",")",":","...","def","__init__","(","self",")",":","...","super","(",")",".__init__","(",")","...","self.list","=","List","(","*","[","CounterWork","(",")",",","CounterWork","(",")","]",")","...","def","run","(","self",")",":","...","for","work","in","self.list",":","...","work.run","(",")","...",">",">",">","flow","=","RootFlow","(",")",">",">",">","flow.run","(",")",">",">",">","assert","flow.list","[","0","]",".counter","==","1","Arguments",":","items",":","A","sequence","of","LightningWork","or","LightningFlow","."]
code: def __init__(self, *items: T):
      """The List Object is used to represents list collection of :class:`~lightning.app.core.work.LightningWork` or
      :class:`~lightning.app.core.flow.LightningFlow`.
  
      Example:
  
          >>> from lightning.app import LightningFlow, LightningWork
          >>> from lightning.app.structures import List
          >>> class CounterWork(LightningWork):
          ...     def __init__(self):
          ...         super().__init__()
          ...         self.counter = 0
          ...     def run(self):
          ...         self.counter += 1
          ...
          >>> class RootFlow(LightningFlow):
          ...     def __init__(self):
          ...         super().__init__()
          ...         self.list = List(*[CounterWork(), CounterWork()])
          ...     def run(self):
          ...         for work in self.list:
          ...             work.run()
          ...
          >>> flow = RootFlow()
          >>> flow.run()
          >>> assert flow.list[0].counter == 1
  
      Arguments:
          items: A sequence of LightningWork or LightningFlow.
  
      """
      super().__init__()
      from lightning.app.runners.backends import Backend
  
      self._name: t.Optional[str] = ""
      self._last_index = 0
      self._backend: t.Optional[Backend] = None
      for item in items:
          self.append(item)
  
file_path: pytorch-lightning/src/lightning/app/structures/list.py
imports: import typing
  from lightning.app.utilities.app_helpers import _LightningAppRef, _set_child_name
label_desc: Use image node_id 1 to create a new List object from inherited base classes: t.List with example: obj = List()