code: def train_and_save_pca(features, n_pca, pca_out_fname):
      logging.info(
          f"Fitting PCA with { n_pca } dimensions to features of shape: {features.shape}"
      )
      pca = PCA(n_pca)
      pca.fit(features)
  
      if pca_out_fname:
          logging.info(f"Saving PCA features to: {pca_out_fname}")
          save_file(pca, pca_out_fname, verbose=False)
          logging.info(f"Saved PCA features to: {pca_out_fname}")
  
      return pca
  
file_path: vissl/vissl/utils/pca.py
imports: import logging
  from typing import Union
  import numpy
  import torch
  from vissl.utils.io import load_file, save_file
label_desc: Use image node_id 2 for calling a global function with example usage: train_and_save_pca(features, n_pca, pca_out_fname) and returns: pca