code: def validate_kube_labels(
      labels: Optional[Dict[str, Optional[str]]],
  ) -> bool:
      """Validate label values.
  
      This validates the kubernetes label values.  It does not validate the keys.
      Ideally, keys should be static and also the validation rules for keys are
      more complex than those for values.  For full validation rules, see:
  
      https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
      """
  
      def validate_label(s: Optional[str]):
          regex_match = (
              r"^(([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9])?$"
          )
          if not s:
              # allow empty label
              return True
          if not re.search(regex_match, s):
              raise KubernetesException(
                  'Invalid value: "%s"\n'
                  "A valid label must be an empty string or one that\n"
                  "  - Consist of alphanumeric, '-', '_' or '.' characters\n"
                  "  - Begins and ends with an alphanumeric character\n"
                  "  - Is at most 63 characters" % s
              )
          return True
  
      return (
          all([validate_label(v) for v in labels.values()])
          if labels
          else True
      )
  
imports: import json
  import math
  import os
  import re
  import shlex
  import time
  from typing import Dict, List, Optional
  import uuid
  from uuid import uuid4
  from metaflow import current, util
  from metaflow.exception import MetaflowException
  from metaflow.metaflow_config import ARGO_EVENTS_EVENT, ARGO_EVENTS_EVENT_BUS, ARGO_EVENTS_EVENT_SOURCE, ARGO_EVENTS_SERVICE_ACCOUNT, ARGO_EVENTS_INTERNAL_WEBHOOK_URL, AWS_SECRETS_MANAGER_DEFAULT_REGION, ARGO_EVENTS_WEBHOOK_AUTH, AZURE_STORAGE_BLOB_SERVICE_ENDPOINT, CARD_AZUREROOT, CARD_GSROOT, CARD_S3ROOT, DATASTORE_SYSROOT_AZURE, DATASTORE_SYSROOT_GS, DATASTORE_SYSROOT_S3, DATATOOLS_S3ROOT, DEFAULT_AWS_CLIENT_PROVIDER, DEFAULT_METADATA, DEFAULT_SECRETS_BACKEND_TYPE, KUBERNETES_FETCH_EC2_METADATA, KUBERNETES_LABELS, KUBERNETES_SANDBOX_INIT_SCRIPT, S3_ENDPOINT_URL, SERVICE_HEADERS, SERVICE_INTERNAL_URL, S3_SERVER_SIDE_ENCRYPTION, OTEL_ENDPOINT
  from metaflow.metaflow_config_funcs import config_values
  from metaflow.mflog import BASH_SAVE_LOGS, bash_capture_logs, export_mflog_env_vars, get_log_tailer, tail_logs
  from .kubernetes_client import KubernetesClient
label_desc: Use image node_id 1 for calling a global function with example usage: validate_kube_labels(labels) and returns: unknown, True, True