code: def tbwatcher_util(internal_hm, backend_interface):
      def tbwatcher_util_helper(
          run, write_function, logdir="./", save=True, root_dir="./"
      ):
          with backend_interface(run=run):
              proto_run = pb.RunRecord()
              run._make_proto_run(proto_run)
  
              run_start = pb.RunStartRequest()
              run_start.run.CopyFrom(proto_run)
  
              request = pb.Request()
              request.run_start.CopyFrom(run_start)
  
              record = pb.Record()
              record.request.CopyFrom(request)
              hm = internal_hm(run.settings)
              hm.handle_request_run_start(record)
              hm._tb_watcher.add(logdir, save, root_dir)
  
              # need to sleep to give time for the tb_watcher delay
              time.sleep(15)
              write_function()
  
      yield tbwatcher_util_helper
  
file_path: wandb/tests/pytest_tests/system_tests/test_core/test_tb_watcher.py
imports: import time
  import pytest
  from wandb.proto import wandb_internal_pb2
  from wandb.sdk.internal import tb_watcher
label_desc: Use image node_id 1 for calling a global function with example usage: tbwatcher_util(internal_hm, backend_interface) without return types