code: def validate_job_labels(job_labels):
      """Validates job labels conform guidelines.
  
      Ref. [resource labels](
      https://cloud.google.com/ai-platform/training/docs/resource-labels)
  
      Args:
          job_labels: String job label to validate.
      Raises:
          ValueError if the given job label is not conformant.
      """
  
      if not job_labels:
          print(
              "No labels provided for the training job."
              "Please consider creating labels to help "
              "with retrieval of job information. "
              "Please see https://cloud.google.com/ai-"
              "platform/training/docs/resource-labels "
              "for more information."
          )
  
      if len(job_labels) > 64:
          raise ValueError(
              "Invalid job labels: too many labels."
              "Expecting at most 64 labels."
              "Received {}.".format(len(job_labels))
          )
  
      for k in job_labels:
          v = job_labels[k]
          if not k or not k[0].islower():
              raise ValueError(
                  "Invalid job labels:"
                  "Label key must start with lowercase letters."
                  "Received {}.".format(k)
              )
          if not v or not v[0].islower():
              raise ValueError(
                  "Invalid job labels:"
                  "Label value must start with lowercase letters."
                  "Received {}.".format(v)
              )
  
          if len(k) > 63:
              raise ValueError(
                  "Invalid job labels:"
                  "Label key is too long."
                  "Expecting at most 63 characters."
                  "Received {}.".format(k)
              )
          if len(v) > 63:
              raise ValueError(
                  "Invalid job labels:"
                  "Label value is too long for key {}."
                  "Expecting at most 63 characters."
                  "Received {}.".format(k, v)
              )
  
          if not re.match(r"^[a-z0-9_-]+$", k):
              raise ValueError(
                  "Invalid job labels:"
                  "Label key can only contain lowercase letters,"
                  "numeric characters, underscores and dashes."
                  "Received: {}.".format(k)
              )
  
          if not re.match(r"^[a-z0-9_-]+$", v):
              raise ValueError(
                  "Invalid job labels:"
                  "Label value can only contain lowercase letters,"
                  "numeric characters, underscores and dashes."
                  "Received: {}.".format(v)
              )
  
file_path: cloud/src/python/tensorflow_cloud/core/gcp.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import re
  import google.auth
label_desc: Use image node_id 8 for calling a global function with example usage: validate_job_labels(job_labels) without return types