code: def _foreach_trace(self, callback: callable):
      if self.traces:
          for run_trace_collection, progress in self.traces.iter_runs():
              if not run_trace_collection:
                  continue
              run = run_trace_collection.run
              self.trace_cache[run.hash] = {"progress": progress}
              run_traces = []
              for trace in run_trace_collection.iter():
                  run_traces.append(trace)
                  callback(trace)
              if run_traces:
                  self.trace_cache[run.hash].update(
                      {"run": run, "traces": run_traces}
                  )
      elif self.requested_traces:
          for trace in self.requested_traces:
              callback(trace)
          assert self.run is not None
          self.trace_cache[self.run.hash] = {
              "run": self.run,
              "traces": self.requested_traces,
          }
  
imports: import asyncio
  import time
  from typing import Iterable, Iterator, List, Tuple, Union, Optional
  from typing import TYPE_CHECKING
  from aim.web.api.runs.utils import ASYNC_SLEEP_INTERVAL, PROGRESS_KEY_SUFFIX, IndexRange, collect_streamable_data, get_run_props, get_run_params
  from aim.web.configs import AIM_PROGRESS_REPORT_INTERVAL
  from aim.sdk.uri_service import URIService, generate_resource_path
  from aim.sdk.sequence_collection import SequenceCollection
  from aim.sdk.sequence import Sequence
  from aim.storage.treeutils import encode_tree
  from aim.storage.context import Context
label_desc: Use image node_id 12 for calling the CustomObjectApi obj's underlying member method code with example usage: obj._foreach_trace(callback) without return types