code: def _validate_config(
      cfg: Optional[Dict[str, Any]],
      obj: Any,
  ) -> None:
      """Validates that all keys in cfg are legitimate configuration options.
  
      Recursively checks if the keys in the cfg dictionary match the attributes of
      the DockerWorkerConfigV2Docker/DockerWorkerConfigV2Lightly instances. If not,
      suggests a best match.
  
      Raises:
          InvalidConfigurationError: If obj is not a valid config.
  
      """
  
      if cfg is None:
          return
  
      for key, item in cfg.items():
          if not hasattr(obj, key):
              possible_options = list(obj.__fields__.keys())
              closest_match = difflib.get_close_matches(
                  word=key,
                  possibilities=possible_options,
                  n=1,
                  cutoff=0.0,
              )[0]
              error_msg = f"Option '{key}' does not exist! Did you mean '{closest_match}'?"
              raise InvalidConfigurationError(error_msg)
          if isinstance(item, dict):
              _validate_config(item, getattr(obj, key))
  
imports: import copy
  import dataclasses
  import difflib
  import json
  import time
  from functools import partial
  from typing import Any, Callable, Dict, Iterator, List, Optional, Type, TypeVar, Union
  from lightly.api import utils
  from lightly.openapi_generated.swagger_client.api_client import ApiClient
  from lightly.openapi_generated.swagger_client.models import CreateDockerWorkerRegistryEntryRequest, DockerRunData, DockerRunScheduledCreateRequest, DockerRunScheduledData, DockerRunScheduledPriority, DockerRunScheduledState, DockerRunState, DockerWorkerConfigV3, DockerWorkerConfigV3CreateRequest, DockerWorkerConfigV3Docker, DockerWorkerConfigV3Lightly, DockerWorkerRegistryEntryData, DockerWorkerType, SelectionConfigV3, SelectionConfigV3Entry, SelectionConfigV3EntryInput, SelectionConfigV3EntryStrategy, TagData
  from lightly.openapi_generated.swagger_client.rest import ApiException
label_desc: Use image node_id 5 for calling a global function with example usage: _validate_config(cfg, obj) without return types