code: def main():
      global TEXT_ENCODING, NEWLINES
  
      usage = "usage: %prog [-h|--help] [options]"
      parser = OptionParser(usage=usage)
      parser.add_option(
          "-b",
          "--binary",
          action="store_true",
          dest="binary",
          default=False,
          help="run binary I/O tests",
      )
      parser.add_option(
          "-t",
          "--text",
          action="store_true",
          dest="text",
          default=False,
          help="run text I/O tests",
      )
      parser.add_option(
          "-r",
          "--read",
          action="store_true",
          dest="read",
          default=False,
          help="run read tests",
      )
      parser.add_option(
          "-w",
          "--write",
          action="store_true",
          dest="write",
          default=False,
          help="run write & modify tests",
      )
      parser.add_option(
          "-E",
          "--encoding",
          action="store",
          dest="encoding",
          default=None,
          help=f"encoding for text tests (default: {TEXT_ENCODING})",
      )
      parser.add_option(
          "-N",
          "--newlines",
          action="store",
          dest="newlines",
          default="lf",
          help="line endings for text tests "
          "(one of: {lf (default), cr, crlf, all})",
      )
      parser.add_option(
          "-m",
          "--io-module",
          action="store",
          dest="io_module",
          default=None,
          help="io module to test (default: builtin open())",
      )
      options, args = parser.parse_args()
      if args:
          parser.error("unexpected arguments")
      NEWLINES = options.newlines.lower()
      if NEWLINES not in ("lf", "cr", "crlf", "all"):
          parser.error(f"invalid 'newlines' option: {NEWLINES!r}")
  
      test_options = ""
      if options.read:
          test_options += "r"
      if options.write:
          test_options += "w"
      elif not options.read:
          test_options += "rw"
      if options.text:
          test_options += "t"
      if options.binary:
          test_options += "b"
      elif not options.text:
          test_options += "tb"
  
      if options.encoding:
          TEXT_ENCODING = options.encoding
  
      if options.io_module:
          globals()["open"] = __import__(
              options.io_module, {}, {}, ["open"]
          ).open
  
      prepare_files()
      run_all_tests(test_options)
  
imports: import itertools
  import os
  import platform
  import re
  import sys
  import time
  from optparse import OptionParser
label_desc: Use image node_id 31 for calling a global function with example usage: main() without return types