class_docstr: Utility class to deal with features extracted with extract_engine
  
  For multi-gpu feature extraction, each GPU saves features corresponding to its
  share of the data. This class offers an API to abstract away the loading of
  these extracted features.
class_docstr_tok: ["Utility","class","to","deal","with","features","extracted","with","extract_engine","For","multi-gpu","feature","extraction",",","each","GPU","saves","features","corresponding","to","its","share","of","the","data",".","This","class","offers","an","API","to","abstract","away","the","loading","of","these","extracted","features","."]
docstr: Merge the features across all GPUs to get the features for the full data.
  
  Args:
      input_dir (str): input path where the features are dumped
      split (str): whether the features are train or test data features
      layer (str): the features correspond to what layer of the model
      flatten_features (bool): whether or not to flatten the features
  
  Returns:
      output (Dict): contains features, targets, inds as the keys
docstr_tok: ["Merge","the","features","across","all","GPUs","to","get","the","features","for","the","full","data",".","Args",":","input_dir","(","str",")",":","input","path","where","the","features","are","dumped","split","(","str",")",":","whether","the","features","are","train","or","test","data","features","layer","(","str",")",":","the","features","correspond","to","what","layer","of","the","model","flatten_features","(","bool",")",":","whether","or","not","to","flatten","the","features","Returns",":","output","(","Dict",")",":","contains","features",",","targets",",","inds","as","the","keys"]
code: def load_features(
      cls,
      input_dir: str,
      split: str,
      layer: str,
      flatten_features: bool = False,
  ):
      """
      Merge the features across all GPUs to get the features for the full data.
  
      Args:
          input_dir (str): input path where the features are dumped
          split (str): whether the features are train or test data features
          layer (str): the features correspond to what layer of the model
          flatten_features (bool): whether or not to flatten the features
  
      Returns:
          output (Dict): contains features, targets, inds as the keys
      """
      logging.info(f"Merging features: {split} {layer}")
  
      # Reassemble each feature shard (dumped by a given rank)
      output_feats, output_targets = {}, {}
      shard_paths = cls.get_shard_file_names(
          input_dir, split=split, layer=layer
      )
      if not shard_paths:
          raise ValueError(f"No features found for {split} {layer}")
  
      for shard_path in shard_paths:
          shard_content = cls.load_feature_shard(shard_path)
          for idx in range(shard_content.num_samples):
              index = shard_content.indices[idx]
              output_feats[index] = shard_content.features[idx]
              output_targets[index] = shard_content.targets[idx]
  
      # Sort the entries by sample index
      indices = np.array(sorted(output_targets.keys()))
      features = np.array([output_feats[i] for i in indices])
      targets = np.array([output_targets[i] for i in indices])
  
      # Return the outputs
      N = len(indices)
      if flatten_features:
          features = features.reshape(N, -1)
      output = {
          "features": features,
          "targets": targets,
          "inds": indices,
      }
      logging.info(f"Features: {output['features'].shape}")
      logging.info(f"Targets: {output['targets'].shape}")
      logging.info(f"Indices: {output['inds'].shape}")
      return output
  
file_path: vissl/vissl/utils/extract_features_utils.py
imports: import logging
  import os
  import re
  from typing import List, NamedTuple
  import numpy
  from iopath.common.file_io import g_pathmgr
  from vissl.utils.io import load_file, makedir
label_desc: Use image node_id 3 for calling the ExtractedFeaturesLoader obj's underlying member method code with example usage: obj.load_features(cls, input_dir, split, layer, flatten_features) and returns: output