code: def _event_to_string(event, allowed_types=str):
      if isinstance(event, allowed_types):
          return event
      try:
          return _events_to_strings[event]
      except (KeyError, TypeError):
          pass
      result = str(event)
      try:
          _events_to_strings[event] = result
      except TypeError:
          pass
      return result
  
imports: import math
  from collections import defaultdict
  from typing import NoReturn, Union
  from weakref import WeakKeyDictionary
  from hypothesis import Verbosity, settings
  from hypothesis._settings import note_deprecation
  from hypothesis.errors import InvalidArgument, UnsatisfiedAssumption
  from hypothesis.internal.compat import BaseExceptionGroup
  from hypothesis.internal.conjecture.data import ConjectureData
  from hypothesis.internal.reflection import get_pretty_function_description
  from hypothesis.internal.validation import check_type
  from hypothesis.reporting import report, verbose_report
  from hypothesis.utils.dynamicvariables import DynamicVariable
  from hypothesis.vendor.pretty import IDKey
label_desc: Use image node_id 9 for calling a global function with example usage: _event_to_string(event, allowed_types) and returns: result, event, _events_to_strings