code: def uri_from_host_port(
      host_arg: str | None, port_arg: str | None, default_port: int
  ) -> str:
      """
      Process the *host* and *port* CLI options.
      Return a URI.
      """
      # Much of distributed depends on a well-known IP being assigned to
      # each entity (Worker, Scheduler, etc.), so avoid "universal" addresses
      # like '' which would listen on all registered IPs and interfaces.
      scheme, loc = parse_address(host_arg or "")
  
      host, port = parse_host_port(
          loc, port_arg if port_arg is not None else default_port
      )
  
      # Note `port = 0` means "choose a random port"
      if port != 0 and port_arg and port != int(port_arg):
          raise ValueError(
              "port number given twice in options: "
              f"host {host_arg} and port {port_arg}"
          )
  
      loc = unparse_host_port(host, port)
      addr = unparse_address(scheme, loc)
  
      return addr
  
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 10 for calling a global function with example usage: uri_from_host_port(host_arg, port_arg, default_port) and returns: addr