code: def _recorder_factory(
      interface_class, interface_method, fn_notify_event
  ):
      """
      internal method, returns the method used to record the events
      """
      signature = inspect.signature(interface_method)
      event_attribute_names = [
          p.name for p in list(signature.parameters.values())[1:]
      ]
  
      def _record(*args, **kwargs) -> None:
          if len(args) > 1:
              raise TypeError(
                  "event methods with more than one argument must be called with named arguments"
              )
  
          if len(args) == 1:
              if len(event_attribute_names) > 1:
                  raise TypeError(
                      "event methods with more than one argument must be called with named arguments"
                  )
  
              value = args[0]
              attribute_name = event_attribute_names[0]
              fn_notify_event(
                  EventRecord(
                      interface_class,
                      interface_method,
                      attributes={attribute_name: value},
                  )
              )
              return
  
          # call the original interface, to raise error on signature mismatch
          for key in kwargs.keys():
              if key not in event_attribute_names:
                  raise TypeError(
                      "got an unexpected keyword argument {}".format(
                          key
                      )
                  )
  
          fn_notify_event(
              EventRecord(
                  interface_class, interface_method, attributes=kwargs
              )
          )
  
      return _record
  
imports: import inspect
  from typing import TypeVar, Type, Callable
  from maze.core.events.event_record import EventRecord
label_desc: Use image node_id 2 for calling a global function with example usage: _recorder_factory(interface_class, interface_method, fn_notify_event) and returns: _record