code: def _is_compat_stream_attr(
      stream: t.TextIO, attr: str, value: t.Optional[str]
  ) -> bool:
      """A stream attribute is compatible if it is equal to the
      desired value or the desired value is unset and the attribute
      has a value.
      """
      stream_value = getattr(stream, attr, None)
      return stream_value == value or (
          value is None and stream_value is not None
      )
  
imports: import codecs
  import io
  import os
  import re
  import sys
  import typing
  from weakref import WeakKeyDictionary
label_desc: Use image node_id 9 for calling a global function with example usage: _is_compat_stream_attr(stream, attr, value) and returns: unknown