code: def _print_tags_for_runs_by_groups(
      obj, system_tags_by_group, all_tags_by_group, by_tag
  ):
      header = [
          "",
          "System tags and *tags*; only *tags* can be modified",
          "--------------------------------------------------------",
          "",
      ]
      obj.echo("\n".join(header), err=False)
      groups = sorted(
          set(
              chain(
                  all_tags_by_group.keys(), system_tags_by_group.keys()
              )
          )
      )
      for group in groups:
          all_tags_in_group = all_tags_by_group.get(group, set())
          system_tags_in_group = system_tags_by_group.get(group, set())
          if by_tag:
              if all_tags_in_group:
                  _print_tags_for_group_by_tag(
                      obj, group, all_tags_in_group, is_system=False
                  )
              if system_tags_in_group:
                  _print_tags_for_group_by_tag(
                      obj, group, system_tags_in_group, is_system=True
                  )
          else:
              _print_tags_for_group(
                  obj,
                  group,
                  system_tags_in_group,
                  all_tags_in_group,
                  skip_per_group_header=(len(all_tags_by_group) == 1),
              )
  
imports: import sys
  from itertools import chain
  from metaflow import namespace
  from metaflow.client import Flow, Run
  from metaflow.current import current
  from metaflow.util import resolve_identity
  from metaflow.exception import CommandException, MetaflowNotFound, MetaflowInternalError
  from metaflow.exception import MetaflowNamespaceMismatch
  from metaflow._vendor import click
label_desc: Use image node_id 1 for calling a global function with example usage: _print_tags_for_runs_by_groups(obj, system_tags_by_group, all_tags_by_group, by_tag) without return types