code: def trigger_visualization_hook(cfg, args):
      default_hooks = cfg.default_hooks
      if "visualization" in default_hooks:
          visualization_hook = default_hooks["visualization"]
          # Turn on visualization
          visualization_hook["enable"] = True
          visualization_hook["draw_gt"] = True
          visualization_hook["draw_pred"] = True
          if args.show:
              visualization_hook["show"] = True
              visualization_hook["wait_time"] = args.wait_time
          if args.show_dir:
              cfg.visualizer["save_dir"] = args.show_dir
              cfg.visualizer["vis_backends"] = [
                  dict(type="LocalVisBackend")
              ]
      else:
          raise RuntimeError(
              "VisualizationHook must be included in default_hooks."
              "refer to usage "
              "\"visualization=dict(type='VisualizationHook')\""
          )
  
      return cfg
  
file_path: mmocr/tools/test.py
imports: import argparse
  import os
  import os.path
  from mmengine.config import Config, DictAction
  from mmengine.registry import RUNNERS
  from mmengine.runner import Runner
label_desc: Use image node_id 2 for calling a global function with example usage: trigger_visualization_hook(cfg, args) and returns: cfg