docstr: The Dict Object is used to represents dict 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 Dict
      >>> 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.dict = Dict(**{"work_0": CounterWork(), "work_1": CounterWork()})
      ...     def run(self):
      ...         for work_name, work in self.dict.items():
      ...             work.run()
      ...
      >>> flow = RootFlow()
      >>> flow.run()
      >>> assert flow.dict["work_0"].counter == 1
  
  Arguments:
      items: A sequence of LightningWork or LightningFlow.
docstr_tok: ["The","Dict","Object","is","used","to","represents","dict","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","Dict",">",">",">","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.dict","=","Dict","(","*","*","{","``","work_0","''",":","CounterWork","(",")",",","``","work_1","''",":","CounterWork","(",")","}",")","...","def","run","(","self",")",":","...","for","work_name",",","work","in","self.dict.items","(",")",":","...","work.run","(",")","...",">",">",">","flow","=","RootFlow","(",")",">",">",">","flow.run","(",")",">",">",">","assert","flow.dict","[","``","work_0","''","]",".counter","==","1","Arguments",":","items",":","A","sequence","of","LightningWork","or","LightningFlow","."]
code: def __init__(self, **kwargs: T):
      """The Dict Object is used to represents dict 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 Dict
          >>> 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.dict = Dict(**{"work_0": CounterWork(), "work_1": CounterWork()})
          ...     def run(self):
          ...         for work_name, work in self.dict.items():
          ...             work.run()
          ...
          >>> flow = RootFlow()
          >>> flow.run()
          >>> assert flow.dict["work_0"].counter == 1
  
      Arguments:
          items: A sequence of LightningWork or LightningFlow.
  
      """
      super().__init__(**kwargs)
      from lightning.app.runners.backends import Backend
  
      self._name: t.Optional[str] = ""
      self._backend: t.Optional[Backend] = None
      for k, v in kwargs.items():
          if "." in k:
              raise Exception(
                  f"The provided name {k} contains . which is forbidden."
              )
          _set_child_name(self, v, k)
  
file_path: pytorch-lightning/src/lightning/app/structures/dict.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 Dict object from inherited base classes: t.Dict with example: obj = Dict()