code: def _to_jsonable(v, compress: bool) -> Any:
      if compress and compression_supported():
          return str(pack(v))
      elif isinstance(v, np.ndarray):
          return v.tolist()
  
      return v
  
imports: from datetime import datetime
  import json
  import logging
  import numpy
  import os
  from urllib.parse import urlparse
  import time
  from ray.air._internal.json import SafeFallbackEncoder
  from ray.rllib.policy.sample_batch import MultiAgentBatch
  from ray.rllib.offline.io_context import IOContext
  from ray.rllib.offline.output_writer import OutputWriter
  from ray.rllib.utils.annotations import override, PublicAPI
  from ray.rllib.utils.compression import pack, compression_supported
  from ray.rllib.utils.typing import FileType, SampleBatchType
  from typing import Any, Dict, List
label_desc: Use image node_id 1 for calling a global function with example usage: _to_jsonable(v, compress) and returns: v, str, v