code: def factorReshape(Q, e, grad, facIndx=0, ftype="act"):
      grad_shape = grad.get_shape()
      if ftype == "act":
          assert e.get_shape()[0] == grad_shape[facIndx]
          expanded_shape = [
              1,
          ] * len(grad_shape)
          expanded_shape[facIndx] = -1
          e = tf.reshape(e, expanded_shape)
      if ftype == "grad":
          assert (
              e.get_shape()[0]
              == grad_shape[len(grad_shape) - facIndx - 1]
          )
          expanded_shape = [
              1,
          ] * len(grad_shape)
          expanded_shape[len(grad_shape) - facIndx - 1] = -1
          e = tf.reshape(e, expanded_shape)
  
      return Q, e
  
imports: import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: factorReshape(Q, e, grad, facIndx, ftype) and returns: Q,  e