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: Remove or keep features and/or examples from the given feature set.
  
  Filtering is done in-place.
  
  Parameters
  ----------
  ids : Optional[List[:class:`skll.types.IdType`]], default=None
      Examples to keep in the FeatureSet. If ``None``, no ID
      filtering takes place.
  
  labels : Optional[List[:class:`skll.types.LabelType`]], default=None
      Labels that we want to retain examples for. If ``None``,
      no label filtering takes place.
  
  features : Optional[List[str]], default=None
      Features to keep in the FeatureSet. To help with
      filtering string-valued features that were converted
      to sequences of boolean features when read in, any
      features in the FeatureSet that contain a ``=`` will be
      split on the first occurrence and the prefix will be
      checked to see if it is in ``features``.
      If ``None``, no feature filtering takes place.
      Cannot be used if FeatureSet uses a FeatureHasher for
      vectorization.
  
  inverse : bool, default=False
      Instead of keeping features and/or examples in lists,
      remove them.
  
  Raises
  ------
  ValueError
      If attempting to use features to filter a ``FeatureSet`` that
      uses a ``FeatureHasher`` vectorizer.
docstr_tok: ["Remove","or","keep","features","and\/or","examples","from","the","given","feature","set",".","Filtering","is","done","in-place",".","Parameters","--","--","--","--","--","ids",":","Optional","[","List","[",":","class",":","`","skll.types.IdType","`","]","]",",","default=None","Examples","to","keep","in","the","FeatureSet",".","If","``","None","``",",","no","ID","filtering","takes","place",".","labels",":","Optional","[","List","[",":","class",":","`","skll.types.LabelType","`","]","]",",","default=None","Labels","that","we","want","to","retain","examples","for",".","If","``","None","``",",","no","label","filtering","takes","place",".","features",":","Optional","[","List","[","str","]","]",",","default=None","Features","to","keep","in","the","FeatureSet",".","To","help","with","filtering","string-valued","features","that","were","converted","to","sequences","of","boolean","features","when","read","in",",","any","features","in","the","FeatureSet","that","contain","a","``","=","``","will","be","split","on","the","first","occurrence","and","the","prefix","will","be","checked","to","see","if","it","is","in","``","features","``",".","If","``","None","``",",","no","feature","filtering","takes","place",".","Can","not","be","used","if","FeatureSet","uses","a","FeatureHasher","for","vectorization",".","inverse",":","bool",",","default=False","Instead","of","keeping","features","and\/or","examples","in","lists",",","remove","them",".","Raises","--","--","--","ValueError","If","attempting","to","use","features","to","filter","a","``","FeatureSet","``","that","uses","a","``","FeatureHasher","``","vectorizer","."]
code: def filter(
      self,
      ids: Optional[List[IdType]] = None,
      labels: Optional[List[LabelType]] = None,
      features: Optional[List[str]] = None,
      inverse: bool = False,
  ) -> None:
      """
      Remove or keep features and/or examples from the given feature set.
  
      Filtering is done in-place.
  
      Parameters
      ----------
      ids : Optional[List[:class:`skll.types.IdType`]], default=None
          Examples to keep in the FeatureSet. If ``None``, no ID
          filtering takes place.
  
      labels : Optional[List[:class:`skll.types.LabelType`]], default=None
          Labels that we want to retain examples for. If ``None``,
          no label filtering takes place.
  
      features : Optional[List[str]], default=None
          Features to keep in the FeatureSet. To help with
          filtering string-valued features that were converted
          to sequences of boolean features when read in, any
          features in the FeatureSet that contain a ``=`` will be
          split on the first occurrence and the prefix will be
          checked to see if it is in ``features``.
          If ``None``, no feature filtering takes place.
          Cannot be used if FeatureSet uses a FeatureHasher for
          vectorization.
  
      inverse : bool, default=False
          Instead of keeping features and/or examples in lists,
          remove them.
  
      Raises
      ------
      ValueError
          If attempting to use features to filter a ``FeatureSet`` that
          uses a ``FeatureHasher`` vectorizer.
      """
      # Construct mask that indicates which examples to keep
      mask = np.ones(len(self), dtype=bool)
      if ids:
          mask = np.logical_and(mask, np.in1d(self.ids, ids))
      if labels and self.labels is not None:
          mask = np.logical_and(mask, np.in1d(self.labels, labels))
  
      if inverse and (labels is not None or ids is not None):
          mask = np.logical_not(mask)
  
      # Remove examples not in mask
      self.ids = self.ids[mask]
      if self.labels is not None:
          self.labels = self.labels[mask]
      if self.features is not None:
          self.features = self.features[mask, :]
  
      # Filter features
      if (
          features
          and self.features is not None
          and self.vectorizer is not None
      ):
          if isinstance(self.vectorizer, FeatureHasher):
              raise ValueError(
                  "FeatureSets with FeatureHasher vectorizers cannot be filtered by feature."
              )
          columns = np.array(
              sorted(
                  {
                      feat_num
                      for feat_name, feat_num in self.vectorizer.vocabulary_.items()
                      if (
                          feat_name in features
                          or feat_name.split("=", 1)[0] in features
                      )
                  }
              )
          )
          if inverse:
              all_columns = np.arange(self.features.shape[1])
              columns = all_columns[
                  np.logical_not(np.in1d(all_columns, columns))
              ]
          self.features = self.features[:, columns]
          self.vectorizer.restrict(columns, indices=True)
  
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 7 for calling the FeatureSet obj's underlying member method code with example usage: obj.filter(ids, labels, features, inverse) without return types