code: def _ensure_json_encodable(x, flag_name):
      try:
          json.dumps(x)
      except TypeError:
          log.warning(
              "cannot serialize value %r for flag %s - coercing to string",
              x,
              flag_name,
          )
          return str(x)
      else:
          return x
  
imports: import argparse
  import json
  import logging
  import sys
  from guild import entry_point_util
  from guild import flag_util
  from guild import log
  from guild import python_util
  from guild import util
label_desc: Use image node_id 12 for calling a global function with example usage: _ensure_json_encodable(x, flag_name) and returns: x, str