code: def replace_entities_with_placeholders(
      text, entities, placeholder_fn
  ):
      """Processes the text in order to replace entity values with placeholders
      as defined by the placeholder function
      """
      if not entities:
          return dict(), text
  
      entities = deduplicate_overlapping_entities(entities)
      entities = sorted(
          entities, key=lambda e: e[RES_MATCH_RANGE][START]
      )
  
      range_mapping = dict()
      processed_text = ""
      offset = 0
      current_ix = 0
      for ent in entities:
          ent_start = ent[RES_MATCH_RANGE][START]
          ent_end = ent[RES_MATCH_RANGE][END]
          rng_start = ent_start + offset
  
          processed_text += text[current_ix:ent_start]
  
          entity_length = ent_end - ent_start
          entity_place_holder = placeholder_fn(ent[ENTITY_KIND])
  
          offset += len(entity_place_holder) - entity_length
  
          processed_text += entity_place_holder
          rng_end = ent_end + offset
          new_range = (rng_start, rng_end)
          range_mapping[new_range] = ent[RES_MATCH_RANGE]
          current_ix = ent_end
  
      processed_text += text[current_ix:]
      return range_mapping, processed_text
  
imports: from __future__ import unicode_literals
  import importlib
  import json
  import numbers
  import re
  from builtins import bytes, str
  from datetime import datetime
  from functools import wraps
  from pathlib import Path
  from future.utils import text_type
  from snips_nlu.constants import END, ENTITY_KIND, RES_MATCH_RANGE, RES_VALUE, START
  from snips_nlu.exceptions import NotTrained, PersistingError
label_desc: Use image node_id 13 for calling a global function with example usage: replace_entities_with_placeholders(text, entities, placeholder_fn) and returns: range_mapping,  processed_text, dict,  text