code: def parse_args(
      parser: argparse.ArgumentParser, allow_unknown=False
  ) -> Args:
      """Parse hyper-parameters from cmdline."""
      if allow_unknown:
          parsed, _ = parser.parse_known_args()
      else:
          parsed = parser.parse_args()
      args = Args()
      optional_args = parser._action_groups[1]
      for action in optional_args._group_actions[1:]:
          arg_name = action.dest
          args[arg_name] = getattr(parsed, arg_name)
      for group in parser._action_groups[2:]:
          group_args = Args()
          for action in group._group_actions:
              arg_name = action.dest
              group_args[arg_name] = getattr(parsed, arg_name)
          if len(group_args) > 0:
              if group.title in args:
                  args[group.title].update(group_args)
              else:
                  args[group.title] = group_args
      return args
  
file_path: PaddleHub/modules/text/text_generation/plato2_en_large/utils/args.py
imports: import argparse
  import json
label_desc: Use image node_id 2 for calling a global function with example usage: parse_args(parser, allow_unknown) and returns: args