code: def tag_list(
      obj,
      run_id,
      hide_system_tags,
      list_all,
      my_runs,
      group_by_tag,
      group_by_run,
      flat,
      arg_run_id,
  ):
      _set_current(obj)
      if (
          run_id is None
          and arg_run_id is None
          and not list_all
          and not my_runs
      ):
          # Assume list_all by default
          list_all = True
  
      if list_all and my_runs:
          raise CommandException(
              "Option --all cannot be used together with --my-runs."
          )
  
      if run_id is not None and arg_run_id is not None:
          raise CommandException(
              "Specify a run either using --run-id or as an argument but not both"
          )
  
      if arg_run_id is not None:
          run_id = arg_run_id
  
      if group_by_run and group_by_tag:
          raise CommandException(
              "Option --group-by-tag cannot be used with --group-by-run"
          )
  
      if flat and (group_by_run or group_by_tag):
          raise CommandException(
              "Option --flat cannot be used with any --group-by-* option"
          )
  
      system_tags_by_some_grouping = dict()
      all_tags_by_some_grouping = dict()
  
      def _populate_tag_groups_from_run(_run):
          if group_by_run:
              if hide_system_tags:
                  all_tags_by_some_grouping[_run.pathspec] = (
                      _run.tags - _run.system_tags
                  )
              else:
                  system_tags_by_some_grouping[
                      _run.pathspec
                  ] = _run.system_tags
                  all_tags_by_some_grouping[_run.pathspec] = _run.tags
          elif group_by_tag:
              for t in _run.tags - _run.system_tags:
                  all_tags_by_some_grouping.setdefault(t, []).append(
                      _run.pathspec
                  )
              if not hide_system_tags:
                  for t in _run.system_tags:
                      system_tags_by_some_grouping.setdefault(
                          t, []
                      ).append(_run.pathspec)
          else:
              if hide_system_tags:
                  all_tags_by_some_grouping.setdefault(
                      "_", set()
                  ).update(_run.tags.difference(_run.system_tags))
              else:
                  system_tags_by_some_grouping.setdefault(
                      "_", set()
                  ).update(_run.system_tags)
                  all_tags_by_some_grouping.setdefault(
                      "_", set()
                  ).update(_run.tags)
  
      pathspecs = []
      if list_all or my_runs:
          user_namespace = resolve_identity() if my_runs else None
          namespace(user_namespace)
          try:
              flow = Flow(pathspec=obj.flow.name)
          except MetaflowNotFound:
              raise CommandException(
                  "Cannot list tags because the flow %s has never been run."
                  % (obj.flow.name,)
              )
          for run in flow.runs():
              _populate_tag_groups_from_run(run)
              pathspecs.append(run.pathspec)
      else:
          run = _get_client_run_obj(obj, run_id, None)
          _populate_tag_groups_from_run(run)
          pathspecs.append(run.pathspec)
  
      if not group_by_run and not group_by_tag:
          # We list all the runs that match to print them out if needed.
          system_tags_by_some_grouping[
              ",".join(pathspecs)
          ] = system_tags_by_some_grouping.get("_", set())
          all_tags_by_some_grouping[
              ",".join(pathspecs)
          ] = all_tags_by_some_grouping.get("_", set())
          if "_" in system_tags_by_some_grouping:
              del system_tags_by_some_grouping["_"]
          if "_" in all_tags_by_some_grouping:
              del all_tags_by_some_grouping["_"]
  
      if flat:
          if len(all_tags_by_some_grouping) != 1:
              raise MetaflowInternalError("Failed to flatten tag set")
          for v in all_tags_by_some_grouping.values():
              for tag in v:
                  obj.echo(tag)
              return
  
      _print_tags_for_runs_by_groups(
          obj,
          system_tags_by_some_grouping,
          all_tags_by_some_grouping,
          group_by_tag,
      )
  
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 12 for calling a global function with example usage: tag_list(obj, run_id, hide_system_tags, list_all, my_runs, group_by_tag, group_by_run, flat, arg_run_id) without return types