code: def bruteforce_inference_one_interaction(self, X, w, order, use_diag):
      n_obj, n_feat = X.shape
      ans = np.zeros(n_obj)
      if order == 2:
          for i in range(n_feat):
              for j in range(0 if use_diag else i + 1, n_feat):
                  x_prod = X[:, i] * X[:, j]
                  w_prod = np.sum(w[1][i, :] * w[1][j, :])
                  denominator = 2.0 ** (order - 1) if use_diag else 1.0
                  ans += x_prod * w_prod / denominator
      elif order == 3:
          for i in range(n_feat):
              for j in range(0 if use_diag else i + 1, n_feat):
                  for k in range(0 if use_diag else j + 1, n_feat):
                      x_prod = X[:, i] * X[:, j] * X[:, k]
                      w_prod = np.sum(
                          w[2][i, :] * w[2][j, :] * w[2][k, :]
                      )
                      denominator = (
                          2.0 ** (order - 1) if use_diag else 1.0
                      )
                      ans += x_prod * w_prod / denominator
      elif order == 4:
          for i in range(n_feat):
              for j in range(0 if use_diag else i + 1, n_feat):
                  for k in range(0 if use_diag else j + 1, n_feat):
                      for ell in range(
                          0 if use_diag else k + 1, n_feat
                      ):
                          x_prod = (
                              X[:, i] * X[:, j] * X[:, k] * X[:, ell]
                          )
                          w_prod = np.sum(
                              w[3][i, :]
                              * w[3][j, :]
                              * w[3][k, :]
                              * w[3][ell, :]
                          )
                          denominator = (
                              2.0 ** (order - 1) if use_diag else 1.0
                          )
                          ans += x_prod * w_prod / denominator
      else:
          assert False
      return ans
  
file_path: tffm/test.py
imports: import unittest
  import numpy
  from tffm import TFFMClassifier
  from scipy import sparse
  import tensorflow
  import pickle
label_desc: Use image node_id 7 for calling the TestFM obj's underlying member method code with example usage: obj.bruteforce_inference_one_interaction(X, w, order, use_diag) and returns: ans