code: def _export_parser_args(
      parser_fn, type_as_str: bool = False, **kwargs
  ):
      from argparse import _StoreAction, _StoreTrueAction
  
      from jina.enums import BetterEnum
      from jina.parsers.helper import (
          _SHOW_ALL_ARGS,
          CastToIntAction,
          KVAppendAction,
      )
  
      port_attr = (
          "help",
          "choices",
          "default",
          "required",
          "option_strings",
          "dest",
      )
      parser = parser_fn(**kwargs)
      parser2 = parser_fn(**kwargs)
      random_dest = set()
      for a, b in zip(parser._actions, parser2._actions):
          if a.default != b.default:
              random_dest.add(a.dest)
      for a in parser._actions:
          if isinstance(
              a,
              (
                  _StoreAction,
                  _StoreTrueAction,
                  KVAppendAction,
                  CastToIntAction,
                  CastHostAction,
              ),
          ):
              if not _SHOW_ALL_ARGS and a.help == argparse.SUPPRESS:
                  continue
              ddd = {p: getattr(a, p) for p in port_attr}
              if isinstance(a, _StoreTrueAction):
                  ddd["type"] = bool
              elif isinstance(a, KVAppendAction):
                  ddd["type"] = dict
              elif isinstance(a, CastToIntAction):
                  ddd["type"] = int
              elif isinstance(a, CastHostAction):
                  ddd["type"] = str
              else:
                  ddd["type"] = a.type
              if ddd["choices"]:
                  ddd["choices"] = [
                      str(k) if isinstance(k, BetterEnum) else k
                      for k in ddd["choices"]
                  ]
                  ddd["type"] = str
              if isinstance(ddd["default"], BetterEnum):
                  ddd["default"] = str(ddd["default"])
                  ddd["type"] = str
              if ddd["type"] == str and (
                  a.nargs == "*" or a.nargs == "+"
              ):
                  ddd["type"] = List[str]
          else:
              continue
  
          if a.dest in random_dest:
              ddd["default_random"] = True
              from jina.helper import random_identity, random_port
  
              if isinstance(a.default, str):
                  ddd["default_factory"] = random_identity.__name__
              elif isinstance(a.default, int):
                  ddd["default_factory"] = random_port.__name__
          else:
              ddd["default_random"] = False
  
          if type_as_str:
              ddd["type"] = getattr(
                  ddd["type"], "__name__", str(ddd["type"])
              )
          ddd["name"] = ddd.pop("dest")
          yield ddd
  
imports: import argparse
  import os
  from typing import List
  from jina.parsers.helper import CastHostAction
label_desc: Use image node_id 2 for calling a global function with example usage: _export_parser_args(parser_fn, type_as_str) without return types