code: def _prepare_ucx_config():
      """Translate dask config options to appropriate UCX config options
  
      Returns
      -------
      tuple
          Options suitable for passing to ``ucp.init`` and additional
          UCX options that will be inserted directly into the environment
          while calling ``ucp.init``.
      """
  
      # configuration of UCX can happen in two ways:
      # 1) high level on/off flags which correspond to UCX configuration
      # 2) explicitly defined UCX configuration flags in distributed.comm.ucx.environment
      # High-level settings in (1) are preferred to settings in (2)
      # Settings in the external environment override both
  
      high_level_options = {}
  
      # if any of the high level flags are set, as long as they are not Null/None,
      # we assume we should configure basic TLS settings for UCX, otherwise we
      # leave UCX to its default configuration
      if any(
          [
              dask.config.get("distributed.comm.ucx.tcp"),
              dask.config.get("distributed.comm.ucx.nvlink"),
              dask.config.get("distributed.comm.ucx.infiniband"),
          ]
      ):
          if dask.config.get("distributed.comm.ucx.rdmacm"):
              tls = "tcp"
              tls_priority = "rdmacm"
          else:
              tls = "tcp"
              tls_priority = "tcp"
  
          # CUDA COPY can optionally be used with ucx -- we rely on the user
          # to define when messages will include CUDA objects.  Note:
          # defining only the Infiniband flag will not enable cuda_copy
          if any(
              [
                  dask.config.get("distributed.comm.ucx.nvlink"),
                  dask.config.get("distributed.comm.ucx.cuda-copy"),
              ]
          ):
              tls = tls + ",cuda_copy"
  
          if dask.config.get("distributed.comm.ucx.infiniband"):
              tls = "rc," + tls
          if dask.config.get("distributed.comm.ucx.nvlink"):
              tls = tls + ",cuda_ipc"
  
          high_level_options = {
              "TLS": tls,
              "SOCKADDR_TLS_PRIORITY": tls_priority,
          }
  
      # Pick up any other ucx environment settings
      environment_options = {}
      for k, v in dask.config.get(
          "distributed.comm.ucx.environment", {}
      ).items():
          # {"some-name": value} is translated to {"UCX_SOME_NAME": value}
          key = "_".join(map(str.upper, ("UCX", *k.split("-"))))
          if (hl_key := key[4:]) in high_level_options:
              logger.warning(
                  f"Ignoring {k}={v} ({key=}) in ucx.environment, "
                  f"preferring {hl_key}={high_level_options[hl_key]} "
                  "from high level options"
              )
          elif key in os.environ:
              # This is only info because setting UCX configuration via
              # environment variables is a reasonably common approach
              logger.info(
                  f"Ignoring {k}={v} ({key=}) in ucx.environment, "
                  f"preferring {key}={os.environ[key]} from external environment"
              )
          else:
              environment_options[key] = v
  
      return high_level_options, environment_options
  
imports: from __future__ import annotations
  import functools
  import logging
  import os
  import struct
  import weakref
  from collections.abc import Awaitable, Callable, Collection
  from typing import TYPE_CHECKING, Any
  from unittest.mock import patch
  import dask
  from dask.utils import parse_bytes
  from distributed.comm.addressing import parse_host_port, unparse_host_port
  from distributed.comm.core import BaseListener, Comm, CommClosedError, Connector
  from distributed.comm.registry import Backend, backends
  from distributed.comm.utils import ensure_concrete_host, from_frames, to_frames
  from distributed.diagnostics.nvml import CudaDeviceInfo, get_device_index_and_uuid, has_cuda_context
  from distributed.protocol.utils import host_array
  from distributed.utils import ensure_ip, get_ip, get_ipv6, log_errors, nbytes
label_desc: Use image node_id 7 for calling a global function with example usage: _prepare_ucx_config() and returns: high_level_options,  environment_options