code: def gateway_model_to_gateway(gateway_model: GatewayModel) -> Gateway:
      ip_address = ""
      instance_id = ""
      if gateway_model.gateway_compute is not None:
          ip_address = gateway_model.gateway_compute.ip_address
          instance_id = gateway_model.gateway_compute.instance_id
      return Gateway(
          name=gateway_model.name,
          ip_address=ip_address,
          instance_id=instance_id,
          region=gateway_model.region,
          wildcard_domain=gateway_model.wildcard_domain,
          default=gateway_model.project.default_gateway_id
          == gateway_model.id,
          created_at=gateway_model.created_at.replace(
              tzinfo=timezone.utc
          ),
          backend=gateway_model.backend.type,
      )
  
imports: import asyncio
  import os
  from datetime import timezone
  from typing import List, Optional, Sequence
  import requests
  from sqlalchemy import delete, select, update
  from sqlalchemy.ext.asyncio import AsyncSession
  import dstack._internal.utils.random_names
  from dstack._internal.core.backends.base.compute import get_dstack_gateway_wheel, get_dstack_runner_version
  from dstack._internal.core.errors import GatewayError, ResourceNotExistsError, ServerClientError
  from dstack._internal.core.models.backends.base import BackendType
  from dstack._internal.core.models.gateways import Gateway
  from dstack._internal.core.models.runs import Job
  from dstack._internal.core.services.ssh.exec import ssh_execute_command
  from dstack._internal.server import settings
  from dstack._internal.server.models import GatewayComputeModel, GatewayModel, ProjectModel
  from dstack._internal.server.services.backends import get_project_backend_by_type_or_error, get_project_backends_with_models
  from dstack._internal.server.services.gateways.ssh import gateway_tunnel_client
  from dstack._internal.server.utils.common import run_async
  from dstack._internal.utils.crypto import generate_rsa_key_pair_bytes
  from dstack._internal.utils.logging import get_logger
label_desc: Use image node_id 3 for calling a global function with example usage: gateway_model_to_gateway(gateway_model) and returns: Gateway