class_docstr: Stores the features produced by any featurizer.
class_docstr_tok: ["Stores","the","features","produced","by","any","featurizer","."]
docstr: Combine features of the same type and level that describe the same attribute.
  
  If sequence features are to be combined, then they must have the same
  sequence dimension.
  
  Args:
    features: Non-empty list of Features  of the same type and level that
      describe the same attribute.
    expected_origins: The expected origins of the given features. This method
      will check that the origin information of each feature is as expected, i.e.
      the origin of the i-th feature in the given list is the i-th origin
      in this list of origins.
  
  Raises:
    `ValueError` will be raised
     - if the given list is empty
     - if there are inconsistencies in the given list of `Features`
     - if the origins aren't as expected
docstr_tok: ["Combine","features","of","the","same","type","and","level","that","describe","the","same","attribute",".","If","sequence","features","are","to","be","combined",",","then","they","must","have","the","same","sequence","dimension",".","Args",":","features",":","Non-empty","list","of","Features","of","the","same","type","and","level","that","describe","the","same","attribute",".","expected_origins",":","The","expected","origins","of","the","given","features",".","This","method","will","check","that","the","origin","information","of","each","feature","is","as","expected",",","i.e",".","the","origin","of","the","i-th","feature","in","the","given","list","is","the","i-th","origin","in","this","list","of","origins",".","Raises",":","`","ValueError","`","will","be","raised","-","if","the","given","list","is","empty","-","if","there","are","inconsistencies","in","the","given","list","of","`","Features","`","-","if","the","origins","are","n't","as","expected"]
code: def combine(
      features_list: List[Features],
      expected_origins: Optional[List[Text]] = None,
  ) -> Features:
      """Combine features of the same type and level that describe the same attribute.
  
      If sequence features are to be combined, then they must have the same
      sequence dimension.
  
      Args:
        features: Non-empty list of Features  of the same type and level that
          describe the same attribute.
        expected_origins: The expected origins of the given features. This method
          will check that the origin information of each feature is as expected, i.e.
          the origin of the i-th feature in the given list is the i-th origin
          in this list of origins.
  
      Raises:
        `ValueError` will be raised
         - if the given list is empty
         - if there are inconsistencies in the given list of `Features`
         - if the origins aren't as expected
      """
      if len(features_list) == 0:
          raise ValueError("Expected a non-empty list of Features.")
      if len(features_list) == 1:
          # nothing to combine here
          return features_list[0]
  
      # Un-Pack the Origin information
      origin_of_combination = [f.origin for f in features_list]
      origin_of_combination = [
          featurizer_name
          for origin in origin_of_combination
          for featurizer_name in (
              origin if isinstance(origin, List) else [origin]
          )
      ]
  
      # Sanity Checks
      # (1) origins must be as expected
      if expected_origins is not None:
          if origin_of_combination is not None:
              for idx, (expected, actual) in enumerate(
                  itertools.zip_longest(
                      expected_origins, origin_of_combination
                  )
              ):
                  if expected != actual:
                      raise ValueError(
                          f"Expected '{expected}' to be the origin of the {idx}-th "
                          f"feature (because of `origin_of_combination`) but found a "
                          f"feature from '{actual}'."
                      )
      # (2) attributes (is_sparse, type, attribute) must coincide
      # Note: we could also use `filter` for this check, but then the error msgs
      # aren't as nice.
      sparseness: Set[bool] = set(f.is_sparse() for f in features_list)
      if len(sparseness) > 1:
          raise ValueError(
              "Expected all Features to have the same sparseness property but "
              "found both (sparse and dense)."
          )
      types: Set[Text] = set(f.type for f in features_list)
      if len(types) > 1:
          raise ValueError(
              f"Expected all Features to have the same type but found the "
              f"following types {types}."
          )
      attributes: Set[Text] = set(f.attribute for f in features_list)
      if len(attributes) > 1:
          raise ValueError(
              f"Expected all Features to describe the same attribute but found "
              f"attributes: {attributes}."
          )
      # (3) dimensions must match
      # Note: We shouldn't have to check sentence-level features here but it doesn't
      # hurt either.
      dimensions = set(f.features.shape[0] for f in features_list)
      if len(dimensions) > 1:
          raise ValueError(
              f"Expected all sequence dimensions to match but found {dimensions}."
          )
  
      # Combine the features
      arbitrary_feature = features_list[0]
      if not arbitrary_feature.is_sparse():
          features = np.concatenate(
              [f.features for f in features_list], axis=-1
          )
      else:
          features = scipy.sparse.hstack(
              [f.features for f in features_list]
          )
      return Features(
          features=features,
          feature_type=arbitrary_feature.type,
          attribute=arbitrary_feature.attribute,
          origin=origin_of_combination,
      )
  
imports: from __future__ import annotations
  from typing import Iterable, Union, Text, Optional, List, Any, Tuple, Dict, Set
  import itertools
  import numpy
  import scipy.sparse
  import rasa.shared.utils.io
  import rasa.shared.nlu.training_data.util
  from rasa.shared.nlu.constants import FEATURE_TYPE_SEQUENCE, FEATURE_TYPE_SENTENCE
label_desc: Use image node_id 14 for calling the Features obj's underlying member method code with example usage: obj.combine(features_list, expected_origins) and returns: Features, features_list