docstr: Incredibly hacky class generator to optionally save / prefix tfevent files.
docstr_tok: ["Incredibly","hacky","class","generator","to","optionally","save","\/","prefix","tfevent","files","."]
code: def _loader(
      self, save: bool = True, namespace: Optional[str] = None
  ) -> "EventFileLoader":
      """Incredibly hacky class generator to optionally save / prefix tfevent files."""
      _loader_interface = self._tbwatcher._interface
      _loader_settings = self._tbwatcher._settings
      try:
          from tensorboard.backend.event_processing import (
              event_file_loader,
          )
      except ImportError:
          raise Exception("Please install tensorboard package")
  
      class EventFileLoader(event_file_loader.EventFileLoader):
          def __init__(self, file_path: str) -> None:
              super().__init__(file_path)
              if save:
                  if REMOTE_FILE_TOKEN in file_path:
                      logger.warning(
                          "Not persisting remote tfevent file: %s",
                          file_path,
                      )
                  else:
                      # TODO: save plugins?
                      logdir = os.path.dirname(file_path)
                      parts = list(os.path.split(logdir))
                      if namespace and parts[-1] == namespace:
                          parts.pop()
                          logdir = os.path.join(*parts)
                      _link_and_save_file(
                          path=file_path,
                          base_path=logdir,
                          interface=_loader_interface,
                          settings=_loader_settings,
                      )
  
      return EventFileLoader
  
imports: import glob
  import logging
  import os
  import queue
  import socket
  import sys
  import threading
  import time
  from typing import TYPE_CHECKING, Any, Dict, List, Optional
  import wandb
  from wandb import util
  from wandb.sdk.interface.interface import GlobStr
  from wandb.sdk.lib import filesystem
  from wandb.viz import CustomChart
  from .None import run
label_desc: Use image node_id 4 for calling the TBDirWatcher obj's underlying member method code with example usage: obj._loader(save, namespace) and returns: EventFileLoader