code: def _patch_file_writer(
      writer: Any,
      module: Any,
      save: bool = True,
      root_logdir: str = "",
  ) -> None:
      # This configures non-TensorFlow Tensorboard logging, or tensorflow <= 1.15
      logdir_hist = []
  
      class TBXEventFileWriter(writer.EventFileWriter):
          def __init__(
              self, logdir: str, *args: Any, **kwargs: Any
          ) -> None:
              logdir_hist.append(logdir)
              root_logdir_arg = root_logdir
              if len(set(logdir_hist)) > 1 and root_logdir == "":
                  wandb.termwarn(
                      "When using several event log directories, "
                      'please call `wandb.tensorboard.patch(root_logdir="...")` before `wandb.init`'
                  )
  
              # if the logdir contains the hostname, the writer was not given a logdir.
              # In this case, the logdir is generated and ends with the hostname,
              # update the root_logdir to match.
              hostname = socket.gethostname()
              search = re.search(rf"-\d+_{hostname}", logdir)
              if search:
                  root_logdir_arg = logdir[: search.span()[1]]
  
              elif root_logdir is not None and not os.path.abspath(
                  logdir
              ).startswith(os.path.abspath(root_logdir)):
                  wandb.termwarn(
                      "Found log directory outside of given root_logdir, "
                      f"dropping given root_logdir for event file in {logdir}"
                  )
                  root_logdir_arg = ""
  
              _notify_tensorboard_logdir(
                  logdir, save=save, root_logdir=root_logdir_arg
              )
  
              super().__init__(logdir, *args, **kwargs)
  
      writer.orig_EventFileWriter = writer.EventFileWriter
      writer.EventFileWriter = TBXEventFileWriter
      wandb.patched["tensorboard"].append([module, "EventFileWriter"])
  
file_path: wandb/wandb/integration/tensorboard/monkeypatch.py
imports: import os
  import re
  import socket
  from typing import Any, Optional
  import wandb
  import wandb.util
label_desc: Use image node_id 4 for calling a global function with example usage: _patch_file_writer(writer, module, save, root_logdir) without return types