code: def test_groupby(
      num_features_per_attribute: Dict[Text, int],
      specified_attributes: Optional[List[Text]],
  ):
      features_list = []
      for attribute, number in num_features_per_attribute.items():
          for idx in range(number):
              matrix = np.full(shape=(1, idx + 1), fill_value=idx + 1)
              config = dict(
                  features=matrix,
                  attribute=attribute,
                  feature_type=FEATURE_TYPE_SEQUENCE,  # doesn't matter
                  origin=f"origin-{idx}",  # doens't matter
              )
              feat = Features(**config)
              features_list.append(feat)
  
      result = Features.groupby_attribute(
          features_list, attributes=specified_attributes
      )
      if specified_attributes is None:
          for attribute, number in num_features_per_attribute.items():
              if number > 0:
                  assert attribute in result
                  assert len(result[attribute]) == number
              else:
                  assert attribute not in result
      else:
          assert set(result.keys()) == set(specified_attributes)
          for attribute in specified_attributes:
              assert attribute in result
              number = num_features_per_attribute.get(attribute, 0)
              assert len(result[attribute]) == number
  
imports: import itertools
  from typing import Optional, Text, List, Dict, Tuple, Any
  import numpy
  import pytest
  import scipy.sparse
  from rasa.shared.nlu.training_data.features import Features
  from rasa.shared.nlu.constants import FEATURE_TYPE_SENTENCE, FEATURE_TYPE_SEQUENCE, TEXT, INTENT
label_desc: Use image node_id 11 for calling a global function with example usage: test_groupby(num_features_per_attribute, specified_attributes) without return types