code: def test_adjust_sparse_layers_for_incremental_training(
      new_sparse_feature_sizes: Dict[Text, Dict[Text, List[int]]],
      old_sparse_feature_sizes: Dict[Text, Dict[Text, List[int]]],
  ):
      """Tests if `adjust_sparse_layers_for_incremental_training` finds and updates
      every `DenseForSparse` layer that has its sparse feature sizes increased.
      """
  
      def init_sparse_to_dense_layer(
          attribute, feature_type, input_size, output_size, reg_lambda
      ):
          kernel_initializer = tf.constant_initializer(
              np.random.random((input_size, output_size))
          )
          layer = layers.DenseForSparse(
              name=f"sparse_to_dense.{attribute}_{feature_type}",
              kernel_initializer=kernel_initializer,
              reg_lambda=reg_lambda,
              units=output_size,
          )
          layer.build(input_shape=input_size)
          return layer
  
      units, reg_lambda = 10, 0.02
      bottom_custom_layer = RasaCustomLayer()
      layer_text_sequence = init_sparse_to_dense_layer(
          attribute=TEXT,
          feature_type=FEATURE_TYPE_SEQUENCE,
          input_size=sum(
              old_sparse_feature_sizes[TEXT][FEATURE_TYPE_SEQUENCE]
          ),
          output_size=units,
          reg_lambda=reg_lambda,
      )
      bottom_tf_layers = {
          "other_layer": object,
          "sparse_to_dense": layer_text_sequence,
      }
      bottom_custom_layer._tf_layers = bottom_tf_layers
      middle_custom_layer = RasaCustomLayer()
      layer_label_sequence = init_sparse_to_dense_layer(
          attribute=LABEL,
          feature_type=FEATURE_TYPE_SEQUENCE,
          input_size=sum(
              old_sparse_feature_sizes[LABEL][FEATURE_TYPE_SEQUENCE]
          ),
          output_size=units,
          reg_lambda=reg_lambda,
      )
      middle_tf_layers = {
          "other_layer": object,
          "sparse_to_dense": layer_label_sequence,
          "another_custom_layer": bottom_custom_layer,
      }
      middle_custom_layer._tf_layers = middle_tf_layers
      top_custom_layer = RasaCustomLayer()
      layer_text_sentence = init_sparse_to_dense_layer(
          attribute=TEXT,
          feature_type=FEATURE_TYPE_SENTENCE,
          input_size=sum(
              old_sparse_feature_sizes[TEXT][FEATURE_TYPE_SENTENCE]
          ),
          output_size=units,
          reg_lambda=reg_lambda,
      )
      top_tf_layers = {
          "other_layer": object,
          "sparse_to_dense": layer_text_sentence,
          "another_custom_layer": middle_custom_layer,
      }
      top_custom_layer._tf_layers = top_tf_layers
  
      top_custom_layer.adjust_sparse_layers_for_incremental_training(
          new_sparse_feature_sizes=new_sparse_feature_sizes,
          old_sparse_feature_sizes=old_sparse_feature_sizes,
          reg_lambda=reg_lambda,
      )
      custom_layers = [
          bottom_custom_layer,
          middle_custom_layer,
          top_custom_layer,
      ]
      for custom_layer in custom_layers:
          dense_layer = custom_layer._tf_layers["sparse_to_dense"]
          layer_attribute = dense_layer.get_attribute()
          layer_feature_type = dense_layer.get_feature_type()
          layer_expected_size = sum(
              new_sparse_feature_sizes[layer_attribute][
                  layer_feature_type
              ]
          )
          dense_layer.build(input_shape=layer_expected_size)
          layer_final_size = dense_layer.get_kernel().shape[0]
          assert layer_attribute and layer_feature_type
          assert layer_final_size == layer_expected_size
  
imports: import pytest
  import tensorflow
  import numpy
  from typing import Text, Union, Any, Dict, List, Type
  from rasa.shared.nlu.constants import TEXT, FEATURE_TYPE_SENTENCE, FEATURE_TYPE_SEQUENCE
  from rasa.utils.tensorflow import layers
  from rasa.utils.tensorflow.rasa_layers import ConcatenateSparseDenseFeatures, RasaFeatureCombiningLayer, RasaSequenceLayer, RasaCustomLayer
  from rasa.utils.tensorflow.constants import DENSE_INPUT_DROPOUT, SPARSE_INPUT_DROPOUT, DROP_RATE, DENSE_DIMENSION, REGULARIZATION_CONSTANT, CONCAT_DIMENSION, CONNECTION_DENSITY, DROP_RATE_ATTENTION, KEY_RELATIVE_ATTENTION, VALUE_RELATIVE_ATTENTION, MAX_RELATIVE_POSITION, UNIDIRECTIONAL_ENCODER, HIDDEN_LAYERS_SIZES, NUM_TRANSFORMER_LAYERS, TRANSFORMER_SIZE, NUM_HEADS, SENTENCE, SEQUENCE, MASKED_LM, LABEL
  from rasa.utils.tensorflow.exceptions import TFLayerConfigException
  from rasa.utils.tensorflow.model_data import FeatureSignature
label_desc: Use image node_id 11 for calling a global function with example usage: test_adjust_sparse_layers_for_incremental_training(new_sparse_feature_sizes, old_sparse_feature_sizes) and returns: layer