code: def _collect_sparse_feature_sizes(
      featurized_example: Dict[Text, List["Features"]],
      training_example: Message,
      featurizers: Optional[List[Text]] = None,
  ) -> Dict[Text, Dict[Text, List[int]]]:
      """Collects sparse feature sizes for all attributes that have sparse features.
  
      Returns sparse feature sizes for each attribute. It could look like this:
      {TEXT: {FEATURE_TYPE_SEQUENCE: [16, 32], FEATURE_TYPE_SENTENCE: [16, 32]}}.
  
      Args:
          featurized_example: a featurized example
          training_example: a training example
          featurizers: the featurizers to consider
  
      Returns:
          A dictionary of attribute to feature sizes.
      """
      sparse_feature_sizes = {}
      sparse_attributes = []
      for attribute, features in featurized_example.items():
          if features and features[0].is_sparse():
              sparse_attributes.append(attribute)
      for attribute in sparse_attributes:
          sparse_feature_sizes[
              attribute
          ] = training_example.get_sparse_feature_sizes(
              attribute=attribute, featurizers=featurizers
          )
      return sparse_feature_sizes
  
imports: import typing
  import copy
  import numpy
  import scipy.sparse
  from collections import defaultdict, OrderedDict
  from typing import List, Optional, Text, Dict, Tuple, Union, Any, DefaultDict, cast
  from rasa.nlu.constants import TOKENS_NAMES
  from rasa.utils.tensorflow.model_data import Data, FeatureArray, ragged_array_to_ndarray
  from rasa.utils.tensorflow.constants import MASK, IDS
  from rasa.shared.nlu.training_data.message import Message
  from rasa.shared.nlu.constants import TEXT, ENTITIES, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_GROUP, ENTITY_ATTRIBUTE_ROLE
label_desc: Use image node_id 2 for calling a global function with example usage: _collect_sparse_feature_sizes(featurized_example, training_example, featurizers) and returns: sparse_feature_sizes