code: def register_observer(observer_fn: ObserverFn) -> None:
      """Register an observer.
  
      Registers an observer. The observer function will be called whenever an event
      triggers.
  
      Silently does nothing if not in an init() context.
  
      Args:
        observer_fn: A function that takes in an Event.
      """
      global _event_observer
      global _event_observer_lock
      with _event_observer_lock:
          if _event_observer:
              _event_observer.register_observer(observer_fn)
  
imports: from concurrent import futures
  import contextlib
  import dataclasses
  import queue
  import threading
  from typing import Any, Callable, List, Optional, Union
  from absl import logging
  from tfx.orchestration.experimental.core import task
  from tfx.utils import status
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: register_observer(observer_fn) without return types