class_docstr: Encapsulate features, labels, and metadata for a given dataset.
  
  Parameters
  ----------
  name : str
      The name of this feature set.
  
  ids : Union[List[str], numpy.ndarray]
      Example IDs for this set.
  
  labels : Optional[Union[List[str], numpy.ndarray], default=None
      Labels for this set.
  
  features : Optional[Union[:class:`skll.types.FeatureDictList`, :class:`numpy.ndarray`]], default=None
      The features for each instance represented as either a
      list of dictionaries or a numpy array (if ``vectorizer`` is
      also specified).
  
  vectorizer : Optional[Union[:class:`sklearn.feature_extraction.DictVectorizer`, :class:`sklearn.feature_extraction.FeatureHasher`], default=None
      Vectorizer which will be used to generate the feature matrix.
  
  Warnings
  --------
  FeatureSets can only be equal if the order of the instances is
  identical because these are stored as lists/arrays. Since scikit-learn's
  ``DictVectorizer`` automatically sorts the underlying feature matrix
  if it is sparse, we do not do any sorting before checking for equality.
  This is not a problem because we _always_ use sparse matrices with
  ``DictVectorizer`` when creating FeatureSets.
  
  Notes
  -----
  If ids, labels, and/or features are not None, the number of rows in
  each array must be equal.
docstr: Initialize a FeatureSet instance.
docstr_tok: ["Initialize","a","FeatureSet","instance","."]
code: def __init__(
      self,
      name: str,
      ids: Union[List[str], np.ndarray],
      labels: Optional[Union[List[str], np.ndarray]] = None,
      features: Optional[
          Union[FeatureDictList, SparseFeatureMatrix]
      ] = None,
      vectorizer: Optional[Union[DictVectorizer, FeatureHasher]] = None,
  ):
      """Initialize a FeatureSet instance."""
      super(FeatureSet, self).__init__()
  
      # clearly define the attribute types
      self.ids: np.ndarray
      self.labels: Optional[np.ndarray]
      self.features: Optional[SparseFeatureMatrix]
      self.vectorizer: Optional[Union[DictVectorizer, FeatureHasher]]
  
      self.name = name
  
      if isinstance(ids, list):
          self.ids = np.array(ids)
      elif isinstance(ids, np.ndarray):
          self.ids = ids
      else:
          raise ValueError("Ids must be a list or numpy array.")
  
      if isinstance(labels, list):
          labels = np.array(labels)
      self.labels = labels
  
      self.vectorizer = vectorizer
  
      # convert features from list of dictionaries to sparse array, if needed
      if isinstance(features, list):
          if self.vectorizer is None:
              self.vectorizer = SkllDictVectorizer(sparse=True)
          features_array: SparseFeatureMatrix = (
              self.vectorizer.fit_transform(features)
          )
          self.features = features_array
      else:
          self.features = features
  
      if self.features is not None:
          num_feats = self.features.shape[0]
          num_ids = self.ids.shape[0]
          if num_feats != num_ids:
              raise ValueError(
                  f"Number of IDs ({num_ids}) does not equal "
                  f"number of feature rows ({num_feats})"
              )
          if self.labels is None:
              self.labels = np.empty(num_feats)
              self.labels.fill(None)
          num_labels = self.labels.shape[0]
          if num_feats != num_labels:
              raise ValueError(
                  f"Number of labels ({num_labels}) does not "
                  f"equal number of feature rows ({num_feats})"
              )
  
imports: from copy import deepcopy
  from typing import Collection, List, Optional, Tuple, Union
  import numpy
  import scipy.sparse
  from pandas import DataFrame
  from sklearn.feature_extraction import DictVectorizer, FeatureHasher
  from skll.data.dict_vectorizer import DictVectorizer
  from skll.types import FeatGenerator, FeatureDictList, IdType, LabelType, SparseFeatureMatrix
label_desc: Use image node_id 1 to create a new FeatureSet object from inherited base classes: object with example: obj = FeatureSet(name, ids, labels, features, vectorizer)