code: def test_add_unknown_words_to_utterances(self):
      # Given
      base_utterances = {
          "data": [
              {"text": "hello "},
              {"text": " you ", "entity": "you"},
              {"text": " how are you "},
              {"text": "cat", "entity": "cat"},
          ]
      }
      utterances = []
      for _ in range(6):
          utterances.append(deepcopy(base_utterances))
  
      rand_it = cycle([0, 1])
  
      def mocked_rand():
          return next(rand_it)
  
      max_unknown_words = 3
      rg_it = cycle([i for i in range(1, max_unknown_words + 1)])
  
      def mocked_randint(a, b):  # pylint: disable=unused-argument
          return next(rg_it)
  
      unknownword_prob = 0.5
  
      random_state = MagicMock()
      random_state_rand = MagicMock()
      random_state_rand.side_effect = mocked_rand
      random_state_choice = MagicMock()
      random_state_choice.side_effect = mocked_randint
  
      random_state.rand = random_state_rand
      random_state.randint = random_state_choice
  
      # When
      replacement_string = "unknownword"
      noisy_utterances = add_unknown_word_to_utterances(
          utterances,
          unknown_word_prob=unknownword_prob,
          replacement_string=replacement_string,
          max_unknown_words=max_unknown_words,
          random_state=random_state,
      )
  
      # Then
      expected_utterances = [
          {
              "data": [
                  {"text": "hello "},
                  {"text": " you ", "entity": "you"},
                  {"text": " how are you "},
                  {"text": "cat", "entity": "cat"},
                  {"text": " unknownword"},
              ]
          },
          {
              "data": [
                  {"text": "hello "},
                  {"text": " you ", "entity": "you"},
                  {"text": " how are you "},
                  {"text": "cat", "entity": "cat"},
              ]
          },
          {
              "data": [
                  {"text": "hello "},
                  {"text": " you ", "entity": "you"},
                  {"text": " how are you "},
                  {"text": "cat", "entity": "cat"},
                  {"text": " unknownword unknownword"},
              ]
          },
          {
              "data": [
                  {"text": "hello "},
                  {"text": " you ", "entity": "you"},
                  {"text": " how are you "},
                  {"text": "cat", "entity": "cat"},
              ]
          },
          {
              "data": [
                  {"text": "hello "},
                  {"text": " you ", "entity": "you"},
                  {"text": " how are you "},
                  {"text": "cat", "entity": "cat"},
                  {"text": " unknownword unknownword unknownword"},
              ]
          },
          {
              "data": [
                  {"text": "hello "},
                  {"text": " you ", "entity": "you"},
                  {"text": " how are you "},
                  {"text": "cat", "entity": "cat"},
              ]
          },
      ]
      self.assertEqual(expected_utterances, noisy_utterances)
  
imports: from __future__ import unicode_literals
  import io
  from copy import deepcopy
  from itertools import cycle
  import numpy
  from future.utils import itervalues, iteritems
  from mock import MagicMock, patch
  from snips_nlu.constants import INTENTS, LANGUAGE_EN, UTTERANCES, LANGUAGE, NOISE
  from snips_nlu.dataset import validate_and_format_dataset, Dataset
  from snips_nlu.intent_classifier.log_reg_classifier_utils import add_unknown_word_to_utterances, build_training_data, generate_noise_utterances, generate_smart_noise, get_noise_it, remove_builtin_slots, text_to_utterance
  from snips_nlu.pipeline.configs import IntentClassifierDataAugmentationConfig, LogRegIntentClassifierConfig
  from snips_nlu.tests.test_log_reg_intent_classifier import get_mocked_augment_utterances
  from snips_nlu.tests.utils import SnipsTest, get_empty_dataset
label_desc: Use image node_id 3 for calling the TestLogRegClassifierUtils obj's underlying member method code with example usage: obj.test_add_unknown_words_to_utterances() and returns: next, next