code: def _check_mode(mode, encoding, newline):
      """Check mode and that encoding and newline are compatible.
  
      Parameters
      ----------
      mode : str
          File open mode.
      encoding : str
          File encoding.
      newline : str
          Newline for text files.
  
      """
      if "t" in mode:
          if "b" in mode:
              raise ValueError("Invalid mode: %r" % (mode,))
      else:
          if encoding is not None:
              raise ValueError(
                  "Argument 'encoding' not supported in binary mode"
              )
          if newline is not None:
              raise ValueError(
                  "Argument 'newline' not supported in binary mode"
              )
  
imports: import os
  import io
  from .._utils import set_module
label_desc: Use image node_id 1 for calling a global function with example usage: _check_mode(mode, encoding, newline) without return types