code: def _update_metadata(metadata, required_resources):
      if required_resources is None:
          return metadata
      metadata = deepcopy(metadata)
      required_gazetteers = required_resources.get(GAZETTEERS, [])
      required_word_clusters = required_resources.get(WORD_CLUSTERS, [])
      for gazetter in required_gazetteers:
          if gazetter not in metadata["gazetteers"]:
              raise ValueError(
                  "Unknown gazetteer for language '%s': '%s'"
                  % (metadata["language"], gazetter)
              )
      for word_clusters in required_word_clusters:
          if word_clusters not in metadata["word_clusters"]:
              raise ValueError(
                  "Unknown word clusters for language '%s': '%s'"
                  % (metadata["language"], word_clusters)
              )
      metadata["gazetteers"] = required_gazetteers
      metadata["word_clusters"] = required_word_clusters
      if not required_resources.get(STEMS, False):
          metadata["stems"] = None
      if not required_resources.get(NOISE, False):
          metadata["noise"] = None
      if not required_resources.get(STOP_WORDS, False):
          metadata["stop_words"] = None
      return metadata
  
imports: from __future__ import unicode_literals
  import json
  from collections import defaultdict
  from copy import deepcopy
  from pathlib import Path
  from future.utils import iteritems
  from snips_nlu.common.utils import get_package_path, is_package, json_string
  from snips_nlu.constants import CUSTOM_ENTITY_PARSER_USAGE, DATA_PATH, GAZETTEERS, NOISE, STEMS, STOP_WORDS, WORD_CLUSTERS, METADATA
  from snips_nlu.entity_parser.custom_entity_parser import CustomEntityParserUsage
label_desc: Use image node_id 3 for calling a global function with example usage: _update_metadata(metadata, required_resources) and returns: metadata, metadata