class_docstr: Log to local file system in `TensorBoard <https://www.tensorflow.org/tensorboard>`_ format.
  
  Implemented using :class:`~tensorboardX.SummaryWriter`. Logs are saved to
  ``os.path.join(root_dir, name, version)``. This is the recommended logger in Lightning Fabric.
  
  Args:
      root_dir: The root directory in which all your experiments with different names and versions will be stored.
      name: Experiment name. Defaults to ``'lightning_logs'``. If it is the empty string then no per-experiment
          subdirectory is used.
      version: Experiment version. If version is not specified the logger inspects the save
          directory for existing versions, then automatically assigns the next available version.
          If it is a string then it is used as the run-specific subdirectory name,
          otherwise ``'version_${version}'`` is used.
      default_hp_metric: Enables a placeholder metric with key `hp_metric` when `log_hyperparams` is
          called without a metric (otherwise calls to ``log_hyperparams`` without a metric are ignored).
      prefix: A string to put at the beginning of all metric keys.
      sub_dir: Sub-directory to group TensorBoard logs. If a ``sub_dir`` argument is passed
          then logs are saved in ``/root_dir/name/version/sub_dir/``. Defaults to ``None`` in which case
          logs are saved in ``/root_dir/name/version/``.
      \**kwargs: Additional arguments used by :class:`tensorboardX.SummaryWriter` can be passed as keyword
          arguments in this logger. To automatically flush to disk, `max_queue` sets the size
          of the queue for pending logs before flushing. `flush_secs` determines how many seconds
          elapses before flushing.
  
  
  Example::
  
      from lightning.fabric.loggers import TensorBoardLogger
  
      logger = TensorBoardLogger("path/to/logs/root", name="my_model")
      logger.log_hyperparams({"epochs": 5, "optimizer": "Adam"})
      logger.log_metrics({"acc": 0.75})
      logger.finalize("success")
code: def log_metrics(
      self, metrics: Mapping[str, float], step: Optional[int] = None
  ) -> None:
      assert (
          rank_zero_only.rank == 0
      ), "experiment tried to log from global_rank != 0"
  
      metrics = _add_prefix(
          metrics, self._prefix, self.LOGGER_JOIN_CHAR
      )
  
      for k, v in metrics.items():
          if isinstance(v, Tensor):
              v = v.item()
  
          if isinstance(v, dict):
              self.experiment.add_scalars(k, v, step)
          else:
              try:
                  self.experiment.add_scalar(k, v, step)
              # TODO(fabric): specify the possible exception
              except Exception as ex:
                  raise ValueError(
                      f"\n you tried to log {v} which is currently not supported. Try a dict or a scalar/tensor."
                  ) from ex
  
imports: import logging
  import os
  from argparse import Namespace
  from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union
  from lightning_utilities.core.imports import RequirementCache
  from torch import Tensor
  from torch.nn import Module
  from typing_extensions import override
  from lightning.fabric.loggers.logger import Logger, rank_zero_experiment
  from lightning.fabric.utilities.cloud_io import _is_dir, get_filesystem
  from lightning.fabric.utilities.logger import _add_prefix, _convert_params, _flatten_dict
  from lightning.fabric.utilities.logger import _sanitize_params
  from lightning.fabric.utilities.rank_zero import rank_zero_only, rank_zero_warn
  from lightning.fabric.utilities.types import _PATH
  from lightning.fabric.wrappers import _unwrap_objects
label_desc: Use image node_id 8 for calling the TensorBoardLogger obj's underlying member method code with example usage: obj.log_metrics(metrics, step) without return types