code: def list_groups(args: Namespace) -> None:
      sess = setup_session(args)
      user_id = None
      if args.groups_user_belongs_to:
          user_id = api.usernames_to_user_ids(
              sess, [args.groups_user_belongs_to]
          )[0]
  
      body = bindings.v1GetGroupsRequest(
          offset=args.offset, limit=args.limit, userId=user_id
      )
      resp = bindings.post_GetGroups(sess, body=body)
      if args.json:
          determined.cli.render.print_json(resp.to_json())
      else:
          if resp.groups is None:
              resp.groups = []
          group_list = []
          for g in resp.groups:
              group = g.group.to_json()
              group["numMembers"] = g.numMembers
              group_list.append(group)
  
          render.render_objects(
              v1GroupHeaders,
              [render.unmarshal(v1GroupHeaders, g) for g in group_list],
          )
  
file_path: determined/harness/determined/cli/user_groups.py
imports: from argparse import Namespace
  from collections import namedtuple
  from typing import Any, List
  import determined.cli.render
  from determined.cli import default_pagination_args, render, require_feature_flag, setup_session
  from determined.common import api
  from determined.common.api import authentication, bindings
  from determined.common.declarative_argparse import Arg, Cmd
label_desc: Use image node_id 2 for calling a global function with example usage: list_groups(args) without return types