class_docstr: A handler for check-ins for a given run.
  
  Uses filesystem to store the check-ins. Handles resumed `Run`s.
  Background thread is used to adjust the rate of check-ins written
  to the filesystem in order to avoid overloading.
  
  Calling `report_successful_finish()` is required to mark the run as
  finished, otherwise the run will be marked as failed.
class_docstr_tok: ["A","handler","for","check-ins","for","a","given","run",".","Uses","filesystem","to","store","the","check-ins",".","Handles","resumed","`","Run","`","s",".","Background","thread","is","used","to","adjust","the","rate","of","check-ins","written","to","the","filesystem","in","order","to","avoid","overloading",".","Calling","`","report_successful_finish","(",")","`","is","required","to","mark","the","run","as","finished",",","otherwise","the","run","will","be","marked","as","failed","."]
docstr: Flush the last check-in.
  If `flag_name` is specified, only the check-ins for the given flag
  will be flushed.
  Otherwise, all the check-ins will be flushed. In this case, the order
  of (active) check-ins (per flag name) will be preserved.
code: def flush(
      self,
      flag_name: Optional[str] = None,
      block: bool = True,
  ) -> None:
      """
      Flush the last check-in.
      If `flag_name` is specified, only the check-ins for the given flag
      will be flushed.
      Otherwise, all the check-ins will be flushed. In this case, the order
      of (active) check-ins (per flag name) will be preserved.
      """
      logger.debug(f"notifying {self}")
  
      with self.reporter_lock:
          flag_names = (
              [flag_name] if flag_name is not None else self.timed_tasks
          )
          with self.flush_condition:
              for flag_name in flag_names:
                  logger.debug(f"flushing {flag_name}")
                  # We add a new task with the highest priority to flush the
                  # last check-in. This task will be processed by the writer
                  # thread immediately.
                  self._schedule(TimedTask(when=0, flag_name=flag_name))
  
              # As there may be no flag names at all, the queue may be
              # untouched. In this case, we need to notify the writer thread
              # explicitly.
              with self.refresh_condition:
                  self.refresh_condition.notify()
  
              # If `block` is set, we wait until the writer thread finishes
              # flushing the last check-in.
              if block:
                  logger.debug("blocking until the writer finishes...")
                  self.flush_condition.wait()
                  logger.debug("done")
  
imports: import math
  import time
  import queue
  import threading
  from collections import defaultdict
  from dataclasses import dataclass, field
  from pathlib import Path
  from typing import ClassVar, Dict, Optional, Tuple, Set, Union, TYPE_CHECKING
  from cachetools import LRUCache
  from aim.sdk.reporter.file_manager import FileManager
  import logging
label_desc: Use image node_id 9 for calling the RunStatusReporter obj's underlying member method code with example usage: obj.flush(flag_name, block) without return types