code: def get_runner_ports(
      ports: Optional[List[int]] = None,
  ) -> Dict[int, int]:
      ports = ports or [client.REMOTE_RUNNER_PORT]
      sockets = []
      try:
          for port in ports:
              s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
              s.bind(
                  ("localhost", 0)
              )  # Bind to a free port provided by the host
              sockets.append((port, s))
          return {port: s.getsockname()[1] for port, s in sockets}
      finally:
          for _, s in sockets:
              s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
              s.close()
  
imports: import asyncio
  import datetime
  import socket
  from datetime import timezone
  from typing import Dict, List, Optional
  from sqlalchemy import update
  from sqlalchemy.ext.asyncio import AsyncSession
  from dstack._internal.core.errors import SSHError
  from dstack._internal.core.models.configurations import ConfigurationType
  from dstack._internal.core.models.runs import Job, JobErrorCode, JobProvisioningData, JobSpec, JobStatus, JobSubmission, RunSpec
  from dstack._internal.core.services.ssh import tunnel
  from dstack._internal.server.models import JobModel, ProjectModel
  from dstack._internal.server.services.backends import get_project_backend_by_type
  from dstack._internal.server.services.jobs.configurators.base import JobConfigurator
  from dstack._internal.server.services.jobs.configurators.dev import DevEnvironmentJobConfigurator
  from dstack._internal.server.services.jobs.configurators.service import ServiceJobConfigurator
  from dstack._internal.server.services.jobs.configurators.task import TaskJobConfigurator
  from dstack._internal.server.services.logging import job_log
  from dstack._internal.server.services.runner import client
  from dstack._internal.server.utils.common import run_async
  from dstack._internal.utils.common import get_current_datetime
  from dstack._internal.utils.logging import get_logger
label_desc: Use image node_id 5 for calling a global function with example usage: get_runner_ports(ports) and returns: unknown