code: def set_context(logger, value):
      """
      Walk the tree of loggers and try to set the context for each handler.
  
      :param logger: logger
      :param value: value to set
      """
      while logger:
          orig_propagate = logger.propagate
          for handler in logger.handlers:
              # Not all handlers need to have context passed in so we ignore
              # the error when handlers do not have set_context defined.
  
              # Don't use getatrr so we have type checking. And we don't care if handler is actually a
              # FileTaskHandler, it just needs to have a set_context function!
              if hasattr(handler, "set_context"):
                  from airflow.utils.log.file_task_handler import (
                      FileTaskHandler,
                  )
  
                  flag = cast(FileTaskHandler, handler).set_context(
                      value
                  )
                  # By default we disable propagate once we have configured the logger, unless that handler
                  # explicitly asks us to keep it on.
                  if flag is not SetContextPropagate.MAINTAIN_PROPAGATE:
                      logger.propagate = False
          if orig_propagate is True:
              # If we were set to propagate before we turned if off, then keep passing set_context up
              logger = logger.parent
          else:
              break
  
imports: from __future__ import annotations
  import abc
  import enum
  import logging
  import sys
  from io import IOBase
  from logging import Handler, StreamHandler
  from typing import IO, TYPE_CHECKING, Any, Optional, TypeVar, cast
  import re2
label_desc: Use image node_id 3 for calling a global function with example usage: set_context(logger, value) without return types