docstr: Checks if the sizes of sparse features have decreased during fine-tuning.
  
  Sparse feature sizes might decrease after changing the training data.
  This can happen for example with `LexicalSyntacticFeaturizer`.
  We don't support this behaviour and we raise an exception if this happens.
  
  Args:
      new_sparse_feature_sizes: sizes of current sparse features.
      old_sparse_feature_sizes: sizes of sparse features the model was
                                previously trained on.
  
  Raises:
      RasaException: When any of the sparse feature sizes decrease
                     from the last time training was run.
docstr_tok: ["Checks","if","the","sizes","of","sparse","features","have","decreased","during","fine-tuning",".","Sparse","feature","sizes","might","decrease","after","changing","the","training","data",".","This","can","happen","for","example","with","`","LexicalSyntacticFeaturizer","`",".","We","do","n't","support","this","behaviour","and","we","raise","an","exception","if","this","happens",".","Args",":","new_sparse_feature_sizes",":","sizes","of","current","sparse","features",".","old_sparse_feature_sizes",":","sizes","of","sparse","features","the","model","was","previously","trained","on",".","Raises",":","RasaException",":","When","any","of","the","sparse","feature","sizes","decrease","from","the","last","time","training","was","run","."]
code: def _check_if_sparse_feature_sizes_decreased(
      new_sparse_feature_sizes: Dict[Text, Dict[Text, List[int]]],
      old_sparse_feature_sizes: Dict[Text, Dict[Text, List[int]]],
  ) -> None:
      """Checks if the sizes of sparse features have decreased during fine-tuning.
  
      Sparse feature sizes might decrease after changing the training data.
      This can happen for example with `LexicalSyntacticFeaturizer`.
      We don't support this behaviour and we raise an exception if this happens.
  
      Args:
          new_sparse_feature_sizes: sizes of current sparse features.
          old_sparse_feature_sizes: sizes of sparse features the model was
                                    previously trained on.
  
      Raises:
          RasaException: When any of the sparse feature sizes decrease
                         from the last time training was run.
      """
      for (
          attribute,
          new_feature_sizes,
      ) in new_sparse_feature_sizes.items():
          old_feature_sizes = old_sparse_feature_sizes[attribute]
          for feature_type, new_sizes in new_feature_sizes.items():
              old_sizes = old_feature_sizes[feature_type]
              for new_size, old_size in zip(new_sizes, old_sizes):
                  if new_size < old_size:
                      raise RasaException(
                          "Sparse feature sizes have decreased from the last time "
                          "training was run. The training data was changed in a way "
                          "that resulted in some features not being present in the "
                          "data anymore. This can happen if you had "
                          "`LexicalSyntacticFeaturizer` in your pipeline. "
                          "The pipeline cannot support incremental training "
                          "in this setting. We recommend you to retrain "
                          "the model from scratch."
                      )
  
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 3 for calling the TransformerRasaModel obj's underlying member method code with example usage: obj._check_if_sparse_feature_sizes_decreased(new_sparse_feature_sizes, old_sparse_feature_sizes) without return types