code: def validate_tag(tag):
      """
      - Tag must be either of bytes-type or unicode-type.
      - If tag is of bytes-type, it must be UTF-8 decodable
      - If tag is of unicode-type, it must be UTF-8 encodable
      - Tag may not be empty string.
      - Tag cannot be too long (500 chars)
      """
      if isinstance(tag, bytes_type):
          if not is_utf8_decodable(tag):
              raise MetaflowTaggingError("Tags must be UTF-8 decodable")
      elif isinstance(tag, unicode_type):
          if not is_utf8_encodable(tag):
              raise MetaflowTaggingError("Tags must be UTF-8 encodable")
      else:
          raise MetaflowTaggingError(
              "Tags must be some kind of string (bytes or unicode), got %s",
              str(type(tag)),
          )
      if not len(tag):
          raise MetaflowTaggingError("Tags must not be empty string")
      if len(tag) > MAX_TAG_SIZE:
          raise MetaflowTaggingError(
              "Tag is too long %d > %d" % (len(tag), MAX_TAG_SIZE)
          )
  
imports: from metaflow.exception import MetaflowTaggingError
  from metaflow.util import unicode_type, bytes_type
label_desc: Use image node_id 4 for calling a global function with example usage: validate_tag(tag) without return types