code: def local_context_safe(key=None, value=None, force=False):
      """
      sets the value on the local context key iff the value is not None and there's no value already set for that key
      (overriding existing value must be requested explicitly by setting `force` param to True).
      :param str key:
      :param value:
      :param bool force: set to True to possibly override existing value on the local context.
      """
      if value is not None and (force or local_env(key) is None):
          with local_context(**{key: value}):
              yield local_env(key)
      else:
          yield local_env(key)
  
imports: from contextlib import contextmanager
  import threading
label_desc: Use image node_id 2 for calling a global function with example usage: local_context_safe(key, value, force) without return types