code: def parse_host_port(
      address: str | tuple[str, int],
      default_port: str | int | None = None,
  ) -> tuple[str, int]:
      """
      Parse an endpoint address given in the form "host:port".
      """
      if isinstance(address, tuple):
          return address
  
      def _fail():
          raise ValueError(
              f"invalid address {address!r}; maybe: ipv6 needs brackets like [::1]"
          )
  
      def _default():
          if default_port is None:
              raise ValueError(
                  f"missing port number in address {address!r}"
              )
          return default_port
  
      if "://" in address:
          _, address = address.split("://")
      if address.startswith("["):
          # IPv6 notation: '[addr]:port' or '[addr]'.
          # The address may contain multiple colons.
          host, sep, tail = address[1:].partition("]")
          if not sep:
              _fail()
          if not tail:
              port = _default()
          else:
              if not tail.startswith(":"):
                  _fail()
              port = tail[1:]
      else:
          # Generic notation: 'addr:port' or 'addr'.
          host, sep, port = address.rpartition(":")
          if not sep:
              host = port
              port = _default()
          elif ":" in host:
              _fail()
  
      return host, int(port)
  
file_path: distributed/distributed/comm/addressing.py
imports: from __future__ import annotations
  import itertools
  import dask
  from distributed.comm import registry
  from distributed.utils import get_ip_interface
label_desc: Use image node_id 4 for calling a global function with example usage: parse_host_port(address, default_port) and returns: host,  int, address, default_port