code: def error_message(scheduler, workers, source, source_name="Client"):
      from distributed.utils import asciitable
  
      source = source.get("packages") if source else "UNKNOWN"
      scheduler = scheduler.get("packages") if scheduler else "UNKNOWN"
      workers = {
          k: v.get("packages") if v else "UNKNOWN"
          for k, v in workers.items()
      }
  
      packages = set()
      packages.update(source)
      packages.update(scheduler)
      for worker in workers:
          packages.update(workers.get(worker))
  
      errs = []
      notes = []
      for pkg in sorted(packages):
          versions = set()
          scheduler_version = (
              scheduler.get(pkg, "MISSING")
              if isinstance(scheduler, dict)
              else scheduler
          )
          if pkg in scheduler_relevant_packages:
              versions.add(scheduler_version)
  
          source_version = (
              source.get(pkg, "MISSING")
              if isinstance(source, dict)
              else source
          )
          versions.add(source_version)
  
          worker_versions = {
              workers[w].get(pkg, "MISSING")
              if isinstance(workers[w], dict)
              else workers[w]
              for w in workers
          }
          versions |= worker_versions
  
          if len(versions) <= 1:
              continue
          if len(worker_versions) == 1:
              worker_versions = list(worker_versions)[0]
          elif len(worker_versions) == 0:
              worker_versions = None
  
          errs.append(
              (pkg, source_version, scheduler_version, worker_versions)
          )
          if pkg in notes_mismatch_package.keys():
              notes.append(f"-  {pkg}: {notes_mismatch_package[pkg]}")
  
      out = {"warning": "", "error": ""}
  
      if errs:
          err_table = asciitable(
              ["Package", source_name, "Scheduler", "Workers"], errs
          )
          err_msg = f"Mismatched versions found\n\n{err_table}"
          if notes:
              err_msg += "\nNotes: \n{}".format("\n".join(notes))
          out["warning"] += err_msg
  
      return out
  
file_path: distributed/distributed/versions.py
imports: from __future__ import annotations
  import importlib
  import os
  import platform
  import struct
  import sys
  from collections.abc import Callable, Iterable
  from itertools import chain
  from types import ModuleType
  from typing import Any
  from packaging.requirements import Requirement
label_desc: Use image node_id 5 for calling a global function with example usage: error_message(scheduler, workers, source, source_name) and returns: out