code: def ls(args: Namespace) -> None:
      session = cli.setup_session(args)
      pools = bindings.get_GetResourcePools(cli.setup_session(args))
      is_priority = check_is_priority(pools, args.resource_pool)
  
      order_by = (
          bindings.v1OrderBy.ASC
          if not args.reverse
          else bindings.v1OrderBy.DESC
      )
  
      def get_with_offset(offset: int) -> bindings.v1GetJobsV2Response:
          return bindings.get_GetJobsV2(
              session,
              resourcePool=args.resource_pool,
              offset=offset,
              limit=args.limit,
              orderBy=order_by,
          )
  
      paginated_resps = api.read_paginated(
          get_with_offset, offset=args.offset, pages=args.pages
      )
      jobs = [j for r in paginated_resps for j in parse_jobv2_resp(r)]
  
      if args.yaml or args.json:
          data = {
              "jobs": [v.to_json() for v in jobs],
          }
          if args.yaml:
              print(util.yaml_safe_dump(data, default_flow_style=False))
          elif args.json:
              render.print_json(data)
          return
  
      headers = [
          "#",
          "ID",
          "Type",
          "Job Name",
          "Priority" if is_priority else "Weight",
          "Submitted",
          "Slots (acquired/needed)",
          "State",
          "User",
      ]
  
      def computed_job_name(job: bindings.v1Job) -> str:
          if job.type == bindings.jobv1Type.EXPERIMENT:
              return f"{job.name} ({job.entityId})"
          else:
              return job.name
  
      values = [
          [
              j.summary.jobsAhead
              if j.summary is not None and j.summary.jobsAhead > -1
              else "N/A",
              j.jobId,
              j.type.value,
              computed_job_name(j)
              if isinstance(j, bindings.v1Job)
              else render.OMITTED_VALUE,
              j.priority if is_priority else j.weight,
              parse_protobuf_timestamp(j.submissionTime).astimezone(
                  datetime.timezone.utc
              )
              if isinstance(j, bindings.v1Job)
              else render.OMITTED_VALUE,
              f"{j.allocatedSlots}/{j.requestedSlots}",
              j.summary.state.value if j.summary is not None else "N/A",
              j.username
              if isinstance(j, bindings.v1Job)
              else render.OMITTED_VALUE,
          ]
          for j in jobs
      ]
      render.tabulate_or_csv(headers, values, as_csv=args.csv)
  
file_path: determined/harness/determined/cli/job.py
imports: import datetime
  from argparse import ONE_OR_MORE, Namespace
  from typing import Any, List, Union
  from determined import cli
  from determined.cli import render
  from determined.common import api, util
  from determined.common.api import authentication, bindings
  from determined.common.declarative_argparse import Arg, Cmd, Group
  from determined.common.util import parse_protobuf_timestamp
label_desc: Use image node_id 2 for calling a global function with example usage: ls(args) and returns: bindings, job, str, job, str, job