code: def _clean_log(obj: Any):
      # Fixes https://github.com/ray-project/ray/issues/10631
      if isinstance(obj, dict):
          return {k: _clean_log(v) for k, v in obj.items()}
      elif isinstance(obj, (list, set)):
          return [_clean_log(v) for v in obj]
      elif isinstance(obj, tuple):
          return tuple(_clean_log(v) for v in obj)
      elif _is_allowed_type(obj):
          return obj
  
      # Else
  
      try:
          # This is what wandb uses internally. If we cannot dump
          # an object using this method, wandb will raise an exception.
          json_dumps_safer(obj)
  
          # This is probably unnecessary, but left here to be extra sure.
          pickle.dumps(obj)
  
          return obj
      except Exception:
          # give up, similar to _SafeFallBackEncoder
          fallback = str(obj)
  
          # Try to convert to int
          try:
              fallback = int(fallback)
              return fallback
          except ValueError:
              pass
  
          # Try to convert to float
          try:
              fallback = float(fallback)
              return fallback
          except ValueError:
              pass
  
          # Else, return string
          return fallback
  
imports: import enum
  import os
  import pickle
  import urllib
  import warnings
  import numpy
  from numbers import Number
  import pyarrow.fs
  from types import ModuleType
  from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
  import ray
  from ray import logger
  from ray.air import session
  from ray.air._internal import usage
  from ray.air.util.node import _force_on_current_node
  from ray.tune.logger import LoggerCallback
  from ray.tune.utils import flatten_dict
  from ray.tune.experiment import Trial
  from ray.train._internal.syncer import DEFAULT_SYNC_TIMEOUT
  from ray._private.storage import _load_class
  from ray.util import PublicAPI
  from ray.util.queue import Queue
label_desc: Use image node_id 4 for calling a global function with example usage: _clean_log(obj) and returns: unknown, obj, unknown, fallback, tuple, fallback, fallback, obj