docstr: Adjusts the model for incremental training.
  
  First we should check if any of the sparse feature sizes has decreased
  and raise an exception if this happens.
  If none of them have decreased and any of them has increased, then the
  function updates `DenseForSparse` layers, compiles the model, fits a sample
  data on it to activate adjusted layer(s) and updates the data signatures.
  
  New and old sparse feature sizes could look like this:
  {TEXT: {FEATURE_TYPE_SEQUENCE: [4, 24, 128], FEATURE_TYPE_SENTENCE: [4, 128]}}
  
  Args:
      data_example: a data example that is stored with the ML component.
      new_sparse_feature_sizes: sizes of current sparse features.
      old_sparse_feature_sizes: sizes of sparse features the model was
                                previously trained on.
docstr_tok: ["Adjusts","the","model","for","incremental","training",".","First","we","should","check","if","any","of","the","sparse","feature","sizes","has","decreased","and","raise","an","exception","if","this","happens",".","If","none","of","them","have","decreased","and","any","of","them","has","increased",",","then","the","function","updates","`","DenseForSparse","`","layers",",","compiles","the","model",",","fits","a","sample","data","on","it","to","activate","adjusted","layer","(","s",")","and","updates","the","data","signatures",".","New","and","old","sparse","feature","sizes","could","look","like","this",":","{","TEXT",":","{","FEATURE_TYPE_SEQUENCE",":","[","4",",","24",",","128","]",",","FEATURE_TYPE_SENTENCE",":","[","4",",","128","]","}","}","Args",":","data_example",":","a","data","example","that","is","stored","with","the","ML","component",".","new_sparse_feature_sizes",":","sizes","of","current","sparse","features",".","old_sparse_feature_sizes",":","sizes","of","sparse","features","the","model","was","previously","trained","on","."]
code: def adjust_for_incremental_training(
      self,
      data_example: Dict[Text, Dict[Text, List[FeatureArray]]],
      new_sparse_feature_sizes: Dict[Text, Dict[Text, List[int]]],
      old_sparse_feature_sizes: Dict[Text, Dict[Text, List[int]]],
  ) -> None:
      """Adjusts the model for incremental training.
  
      First we should check if any of the sparse feature sizes has decreased
      and raise an exception if this happens.
      If none of them have decreased and any of them has increased, then the
      function updates `DenseForSparse` layers, compiles the model, fits a sample
      data on it to activate adjusted layer(s) and updates the data signatures.
  
      New and old sparse feature sizes could look like this:
      {TEXT: {FEATURE_TYPE_SEQUENCE: [4, 24, 128], FEATURE_TYPE_SENTENCE: [4, 128]}}
  
      Args:
          data_example: a data example that is stored with the ML component.
          new_sparse_feature_sizes: sizes of current sparse features.
          old_sparse_feature_sizes: sizes of sparse features the model was
                                    previously trained on.
      """
      self._check_if_sparse_feature_sizes_decreased(
          new_sparse_feature_sizes=new_sparse_feature_sizes,
          old_sparse_feature_sizes=old_sparse_feature_sizes,
      )
      if self._sparse_feature_sizes_have_increased(
          new_sparse_feature_sizes=new_sparse_feature_sizes,
          old_sparse_feature_sizes=old_sparse_feature_sizes,
      ):
          self._update_dense_for_sparse_layers(
              new_sparse_feature_sizes, old_sparse_feature_sizes
          )
          self._compile_and_fit(data_example)
  
imports: import time
  import random
  import tensorflow
  import numpy
  import logging
  import os
  from collections import defaultdict
  from typing import List, Text, Dict, Tuple, Union, Optional, Any, TYPE_CHECKING
  from keras.utils import tf_utils
  from keras import Model
  from rasa.shared.constants import DIAGNOSTIC_DATA
  from rasa.utils.tensorflow.constants import LABEL, IDS, INTENT_CLASSIFICATION, SENTENCE, SEQUENCE_LENGTH, RANDOM_SEED, EMBEDDING_DIMENSION, REGULARIZATION_CONSTANT, SIMILARITY_TYPE, CONNECTION_DENSITY, NUM_NEG, LOSS_TYPE, MAX_POS_SIM, MAX_NEG_SIM, USE_MAX_NEG_SIM, NEGATIVE_MARGIN_SCALE, SCALE_LOSS, LEARNING_RATE, CONSTRAIN_SIMILARITIES, MODEL_CONFIDENCE, RUN_EAGERLY
  from rasa.utils.tensorflow.model_data import RasaModelData, FeatureSignature, FeatureArray
  import rasa.utils.train_utils
  from rasa.utils.tensorflow import layers
  from rasa.utils.tensorflow import rasa_layers
  from rasa.utils.tensorflow.data_generator import RasaDataGenerator, RasaBatchDataGenerator
  from rasa.shared.nlu.constants import TEXT
  from rasa.shared.exceptions import RasaException
  from rasa.utils.tensorflow.types import BatchData, MaybeNestedBatchData
label_desc: Use image node_id 2 for calling the TransformerRasaModel obj's underlying member method code with example usage: obj.adjust_for_incremental_training(data_example, new_sparse_feature_sizes, old_sparse_feature_sizes) without return types