code: def get_train_err(htfa, data, F):
      """Calcuate training error
  
      Parameters
      ----------
  
      htfa : HTFA
          An instance of HTFA, factor anaysis class in BrainIAK.
  
      data : 2D array
          Input data to HTFA.
  
      F : 2D array
          HTFA factor matrix.
  
      Returns
      -------
      float
          Returns root mean squared error on training.
  
      """
  
      W = htfa.get_weights(data, F)
      return recon_err(data, F, W)
  
file_path: brainiak/examples/factoranalysis/htfa_cv_example.py
imports: import os
  import sys
  import math
  import requests
  import scipy.io
  import numpy
  from mpi4py import MPI
  from subprocess import call
  from scipy.stats import stats
  from sklearn import model_selection
  from sklearn.metrics import mean_squared_error
label_desc: Use image node_id 2 for calling a global function with example usage: get_train_err(htfa, data, F) and returns: recon_err