class_docstr: Write all scalars to a tensorboard file.
code: def write(self):
      storage = get_event_storage()
      new_last_write = self._last_write
      for k, (v, iter) in storage.latest_with_smoothing_hint(
          self._window_size
      ).items():
          if iter > self._last_write:
              self._writer.add_scalar(k, v, iter)
              new_last_write = max(new_last_write, iter)
      self._last_write = new_last_write
  
      # storage.put_{image,histogram} is only meant to be used by
      # tensorboard writer. So we access its internal fields directly from here.
      if len(storage._vis_data) >= 1:
          for img_name, img, step_num in storage._vis_data:
              self._writer.add_image(img_name, img, step_num)
          # Storage stores all image data and rely on this writer to clear them.
          # As a result it assumes only one writer will use its image data.
          # An alternative design is to let storage store limited recent
          # data (e.g. only the most recent image) that all writers can access.
          # In that case a writer may not see all image data if its period is long.
          storage.clear_images()
  
      if len(storage._histograms) >= 1:
          for params in storage._histograms:
              self._writer.add_histogram_raw(**params)
          storage.clear_histograms()
  
imports: import datetime
  import json
  import logging
  import os
  import time
  from collections import defaultdict
  from contextlib import contextmanager
  from functools import cached_property
  from typing import Optional
  import torch
  from fvcore.common.history_buffer import HistoryBuffer
  from detectron2.utils.file_io import PathManager
label_desc: Use image node_id 3 for calling the TensorboardXWriter obj's underlying member method code with example usage: obj.write() without return types