code: def _apply_feature_selection(keep, feature_matrix, features=None):
      new_matrix = feature_matrix[keep]
      new_feature_names = set(new_matrix.columns)
  
      if features is not None:
          new_features = []
          for f in features:
              if f.number_output_features > 1:
                  slices = [
                      f[i]
                      for i in range(f.number_output_features)
                      if f[i].get_name() in new_feature_names
                  ]
                  if len(slices) == f.number_output_features:
                      new_features.append(f)
                  else:
                      new_features.extend(slices)
              else:
                  if f.get_name() in new_feature_names:
                      new_features.append(f)
  
          return new_matrix, new_features
      return new_matrix
  
imports: import pandas
  from woodwork.logical_types import Boolean, BooleanNullable
label_desc: Use image node_id 5 for calling a global function with example usage: _apply_feature_selection(keep, feature_matrix, features) and returns: new_matrix, new_matrix,  new_features