code: def parse_args(argv):
      """
      Parse commandline arguments.
  
      Arguments:
          argv -- An argument list without the program name.
      """
      output_funcs = {
          "json": dump_as_json,
          "tsv": dump_as_two_item_tsv,
      }
      default_output_func_key = "json"
  
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "-v",
          "--version",
          action="version",
          version="%(prog)s {0}".format(__version__),
      )
      parser.add_argument(
          "input",
          metavar="inpath",
          nargs="*",
          help="Input transaction file (default: stdin).",
          type=argparse.FileType("r"),
          default=[sys.stdin],
      )
      parser.add_argument(
          "-o",
          "--output",
          metavar="outpath",
          help="Output file (default: stdout).",
          type=argparse.FileType("w"),
          default=sys.stdout,
      )
      parser.add_argument(
          "-l",
          "--max-length",
          metavar="int",
          help="Max length of relations (default: infinite).",
          type=int,
          default=None,
      )
      parser.add_argument(
          "-s",
          "--min-support",
          metavar="float",
          help="Minimum support ratio (must be > 0, default: 0.1).",
          type=float,
          default=0.1,
      )
      parser.add_argument(
          "-c",
          "--min-confidence",
          metavar="float",
          help="Minimum confidence (default: 0.5).",
          type=float,
          default=0.5,
      )
      parser.add_argument(
          "-t",
          "--min-lift",
          metavar="float",
          help="Minimum lift (default: 0.0).",
          type=float,
          default=0.0,
      )
      parser.add_argument(
          "-d",
          "--delimiter",
          metavar="str",
          help="Delimiter for items of transactions (default: tab).",
          type=str,
          default="\t",
      )
      parser.add_argument(
          "-f",
          "--out-format",
          metavar="str",
          help="Output format ({0}; default: {1}).".format(
              ", ".join(output_funcs.keys()), default_output_func_key
          ),
          type=str,
          choices=output_funcs.keys(),
          default=default_output_func_key,
      )
      args = parser.parse_args(argv)
  
      args.output_func = output_funcs[args.out_format]
      return args
  
imports: import sys
  import csv
  import argparse
  import json
  import os
  from collections import namedtuple
  from itertools import combinations
  from itertools import chain
label_desc: Use image node_id 6 for calling a global function with example usage: parse_args(argv) and returns: args