code: def _validate_and_format_intent(intent, entities):
      validate_type(intent, dict, "intent")
      validate_key(intent, UTTERANCES, object_label="intent dict")
      validate_type(intent[UTTERANCES], list, object_label="utterances")
      for utterance in intent[UTTERANCES]:
          validate_type(utterance, dict, object_label="utterance")
          validate_key(utterance, DATA, object_label="utterance")
          validate_type(
              utterance[DATA], list, object_label="utterance data"
          )
          for chunk in utterance[DATA]:
              validate_type(chunk, dict, object_label="utterance chunk")
              validate_key(chunk, TEXT, object_label="chunk")
              if ENTITY in chunk or SLOT_NAME in chunk:
                  mandatory_keys = [ENTITY, SLOT_NAME]
                  validate_keys(
                      chunk, mandatory_keys, object_label="chunk"
                  )
                  if is_builtin_entity(chunk[ENTITY]):
                      continue
                  else:
                      validate_key(
                          entities, chunk[ENTITY], object_label=ENTITIES
                      )
      return intent
  
file_path: snips-nlu/snips_nlu/dataset/validation.py
imports: from __future__ import division, unicode_literals
  import json
  from builtins import str
  from collections import Counter
  from copy import deepcopy
  from future.utils import iteritems, itervalues
  from snips_nlu.common.dataset_utils import validate_key, validate_keys, validate_type
  from snips_nlu.constants import AUTOMATICALLY_EXTENSIBLE, CAPITALIZE, DATA, ENTITIES, ENTITY, INTENTS, LANGUAGE, MATCHING_STRICTNESS, SLOT_NAME, SYNONYMS, TEXT, USE_SYNONYMS, UTTERANCES, VALIDATED, VALUE, LICENSE_INFO
  from snips_nlu.dataset import extract_utterance_entities, Dataset
  from snips_nlu.entity_parser.builtin_entity_parser import BuiltinEntityParser, is_builtin_entity
  from snips_nlu.exceptions import DatasetFormatError
  from snips_nlu.preprocessing import tokenize_light
  from snips_nlu.string_variations import get_string_variations
label_desc: Use image node_id 2 for calling a global function with example usage: _validate_and_format_intent(intent, entities) and returns: intent