code: def force_bson_encodeable(obj):
      import bson
  
      if isinstance(obj, dict):
          try:
              bson.BSON.encode(obj, check_keys=True)
              return obj
          except bson.InvalidDocument:
              return {
                  force_valid_bson_key(k): force_bson_encodeable(v)
                  for k, v in obj.items()
              }
  
      elif opt.has_numpy and isinstance(obj, opt.np.ndarray):
          return obj
      else:
          try:
              bson.BSON.encode({"dict_just_for_testing": obj})
              return obj
          except bson.InvalidDocument:
              return str(obj)
  
imports: from typing import Optional, Union
  import mimetypes
  import os.path
  import pickle
  import re
  import sys
  import time
  from tempfile import NamedTemporaryFile
  import warnings
  import sacred.optional
  from sacred.commandline_options import cli_option
  from sacred.dependencies import get_digest
  from sacred.observers.base import RunObserver
  from sacred.observers.queue import QueueObserver
  from sacred.serializer import flatten
  from sacred.utils import ObserverError, PathType
  import pkg_resources
label_desc: Use image node_id 2 for calling a global function with example usage: force_bson_encodeable(obj) and returns: obj, obj, unknown, obj, str