code: def _log(
      tf_summary_str_or_pb: Any,
      history: Optional["TBHistory"] = None,
      step: int = 0,
      namespace: str = "",
      **kwargs: Any,
  ) -> None:
      """Logs a tfsummary to wandb.
  
      Can accept a tf summary string or parsed event.  Will use wandb.run.history unless a
      history object is passed.  Can optionally namespace events.  Results are committed
      when step increases for this namespace.
  
      NOTE: This assumes that events being passed in are in chronological order
      """
      global STEPS
      global RATE_LIMIT_SECONDS
      # To handle multiple global_steps, we keep track of them here instead
      # of the global log
      last_step = STEPS.get(namespace, {"step": 0})
  
      # Commit our existing data if this namespace increased its step
      commit = False
      if last_step["step"] < step:
          commit = True
  
      log_dict = tf_summary_to_dict(tf_summary_str_or_pb, namespace)
      if log_dict is None:
          # not an event, just return
          return
  
      # Pass timestamp to history for loading historic data
      timestamp = log_dict.get("_timestamp", time.time())
      # Store our initial timestamp
      if STEPS["global"]["last_log"] is None:
          STEPS["global"]["last_log"] = timestamp
      # Rollup events that share the same step across namespaces
      if commit and step == STEPS["global"]["step"]:
          commit = False
      # Always add the biggest global_step key for non-default namespaces
      if step > STEPS["global"]["step"]:
          STEPS["global"]["step"] = step
      if namespace != "":
          log_dict["global_step"] = STEPS["global"]["step"]
  
      # Keep internal step counter
      STEPS[namespace] = {"step": step}
  
      if commit:
          # Only commit our data if we're below the rate limit or don't have one
          if (
              RATE_LIMIT_SECONDS is None
              or timestamp - STEPS["global"]["last_log"]
              >= RATE_LIMIT_SECONDS
          ):
              if history is None:
                  if wandb.run is not None:
                      wandb.run._log({})
              else:
                  history.add({})
  
          STEPS["global"]["last_log"] = timestamp
  
      if history is None:
          if wandb.run is not None:
              wandb.run._log(log_dict, commit=False)
      else:
          history._row_update(log_dict)
  
file_path: wandb/wandb/integration/tensorboard/log.py
imports: import io
  import re
  import time
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
  import wandb
  import wandb.util
  from wandb.sdk.lib import telemetry
  from wandb.viz import custom_chart
label_desc: Use image node_id 6 for calling a global function with example usage: _log(tf_summary_str_or_pb, history, step, namespace) without return types