code: def parse_args(argv):
      """Parses command line arguments."""
      parser = argparse_flags.ArgumentParser(
          formatter_class=argparse.ArgumentDefaultsHelpFormatter
      )
  
      # High-level options.
      parser.add_argument(
          "--url_prefix",
          default=URL_PREFIX,
          help="URL prefix for downloading model metagraphs.",
      )
      parser.add_argument(
          "--metagraph_cache",
          default=METAGRAPH_CACHE,
          help="Directory where to cache model metagraphs.",
      )
      subparsers = parser.add_subparsers(
          title="commands",
          dest="command",
          help="Invoke '<command> -h' for more information.",
      )
  
      # 'compress' subcommand.
      compress_cmd = subparsers.add_parser(
          "compress",
          formatter_class=argparse.ArgumentDefaultsHelpFormatter,
          description="Reads a PNG file, compresses it using the given model, and "
          "writes a TFCI file.",
      )
      compress_cmd.add_argument(
          "model",
          help="Unique model identifier. See 'models' command for options. If "
          "'target_bpp' is provided, don't specify the index at the end of "
          "the model identifier.",
      )
      compress_cmd.add_argument(
          "--rd_parameter",
          "-r",
          type=float,
          help="Rate-distortion parameter (for some models). Ignored if "
          "'target_bpp' is set.",
      )
      compress_cmd.add_argument(
          "--rd_parameter_tolerance",
          type=float,
          default=2**-4,
          help="Tolerance for rate-distortion parameter. Only used if 'target_bpp' "
          "is set for some models, to determine when to stop the binary "
          "search.",
      )
      compress_cmd.add_argument(
          "--target_bpp",
          "-b",
          type=float,
          help="Target bits per pixel. If provided, a binary search is used to try "
          "to match the given bpp as close as possible. In this case, don't "
          "specify the index at the end of the model identifier. It will be "
          "automatically determined.",
      )
      compress_cmd.add_argument(
          "--bpp_strict",
          action="store_true",
          help="Try never to exceed 'target_bpp'. Ignored if 'target_bpp' is not "
          "set.",
      )
  
      # 'decompress' subcommand.
      decompress_cmd = subparsers.add_parser(
          "decompress",
          formatter_class=argparse.ArgumentDefaultsHelpFormatter,
          description="Reads a TFCI file, reconstructs the image using the model "
          "it was compressed with, and writes back a PNG file.",
      )
  
      # 'models' subcommand.
      subparsers.add_parser(
          "models",
          formatter_class=argparse.ArgumentDefaultsHelpFormatter,
          description="Lists available trained models. Requires an internet "
          "connection.",
      )
  
      tensors_cmd = subparsers.add_parser(
          "tensors",
          formatter_class=argparse.ArgumentDefaultsHelpFormatter,
          description="Lists names of internal tensors of a given model.",
      )
      tensors_cmd.add_argument(
          "model",
          help="Unique model identifier. See 'models' command for options.",
      )
  
      dump_cmd = subparsers.add_parser(
          "dump",
          formatter_class=argparse.ArgumentDefaultsHelpFormatter,
          description="Dumps values of given internal tensors of a model in "
          "NumPy's .npz format.",
      )
      dump_cmd.add_argument(
          "model",
          help="Unique model identifier. See 'models' command for options.",
      )
      dump_cmd.add_argument(
          "--tensor",
          "-t",
          nargs="+",
          help="Name(s) of tensor(s) to dump. Must provide at least one. See "
          "'tensors' command for options.",
      )
  
      # Arguments for 'compress', 'decompress', and 'dump'.
      for cmd, ext in (
          (compress_cmd, ".tfci"),
          (decompress_cmd, ".png"),
          (dump_cmd, ".npz"),
      ):
          cmd.add_argument("input_file", help="Input filename.")
          cmd.add_argument(
              "output_file",
              nargs="?",
              help=f"Output filename (optional). If not provided, appends '{ext}' to "
              f"the input filename.",
          )
  
      # Parse arguments.
      args = parser.parse_args(argv[1:])
      if args.command is None:
          parser.print_usage()
          sys.exit(2)
      return args
  
imports: import argparse
  import io
  import os
  import sys
  import urllib
  from absl import app
  from absl.flags import argparse_flags
  import numpy
  import tensorflow
  import tensorflow_compression
label_desc: Use image node_id 11 for calling a global function with example usage: parse_args(argv) and returns: args