code: def test_structure_with_iterate_and_fault_tolerance(
      run_once_iterable, cache_calls, use_list
  ):
      class DummyFlow(LightningFlow):
          def __init__(self):
              super().__init__()
              self.counter = 0
  
          def run(self):
              pass
  
      class RootFlow(LightningFlow):
          def __init__(self, use_list, run_once_iterable, cache_calls):
              super().__init__()
              self.looping = 0
              self.run_once_iterable = run_once_iterable
              self.restarting = False
              if use_list:
                  self.iter = List(
                      CounterWork(cache_calls),
                      CounterWork(cache_calls),
                      CounterWork(cache_calls),
                      CounterWork(cache_calls),
                      DummyFlow(),
                  )
              else:
                  self.iter = Dict(
                      **{
                          "0": CounterWork(cache_calls),
                          "1": CounterWork(cache_calls),
                          "2": CounterWork(cache_calls),
                          "3": CounterWork(cache_calls),
                          "4": DummyFlow(),
                      }
                  )
  
          def run(self):
              for work_idx, work in self.experimental_iterate(
                  enumerate(self.iter), run_once=self.run_once_iterable
              ):
                  if not self.restarting and work_idx == 1:
                      # gives time to the delta to be sent.
                      self.stop()
                  if isinstance(work, str) and isinstance(
                      self.iter, Dict
                  ):
                      work = self.iter[work]
                  work.run()
              if self.looping > 0:
                  self.stop()
              self.looping += 1
  
      app = LightningApp(
          RootFlow(use_list, run_once_iterable, cache_calls)
      )
      MultiProcessRuntime(app, start_server=False).dispatch()
      assert app.root.iter[0 if use_list else "0"].counter == 1
      assert app.root.iter[1 if use_list else "1"].counter == 0
      assert app.root.iter[2 if use_list else "2"].counter == 0
      assert app.root.iter[3 if use_list else "3"].counter == 0
  
      app = LightningApp(
          RootFlow(use_list, run_once_iterable, cache_calls)
      )
      app.root.restarting = True
      MultiProcessRuntime(app, start_server=False).dispatch()
  
      expected_value = (
          1 if run_once_iterable else 1 if cache_calls else 2
      )
      assert (
          app.root.iter[0 if use_list else "0"].counter
          == expected_value
      )
      assert (
          app.root.iter[1 if use_list else "1"].counter
          == expected_value
      )
      assert (
          app.root.iter[2 if use_list else "2"].counter
          == expected_value
      )
      assert (
          app.root.iter[3 if use_list else "3"].counter
          == expected_value
      )
  
imports: import os
  from copy import deepcopy
  import pytest
  from lightning.app import LightningApp, LightningFlow, LightningWork
  from lightning.app.runners import MultiProcessRuntime
  from lightning.app.storage.payload import Payload
  from lightning.app.structures import Dict, List
  from lightning.app.testing.helpers import EmptyFlow
  from lightning.app.utilities.enum import CacheCallsKeys, WorkStageStatus
  from lightning.app.utilities.imports import _IS_WINDOWS
label_desc: Use image node_id 5 for calling a global function with example usage: test_structure_with_iterate_and_fault_tolerance(run_once_iterable, cache_calls, use_list) without return types