def _logistic(x):
 x = np.array(x)
 if (x.ndim == 0):
  y = np.reshape(x, (1, 1, 1))
 elif (x.ndim == 1):
  y = np.reshape(x, (len(x), 1, 1))
 elif (x.ndim == 2):
  y = np.reshape(x, (x.shape[0], 1, x.shape[1]))
 elif (x.ndim == 3):
  y = x
 else:
  raise NotImplementedError
 tmp = np.c_[(np.zeros((y.shape[(-1)], y.shape[1], 1)), y.T)].T
 evaluated = np.reshape(np.exp((y - logsumexp(tmp, axis=0))), x.shape)
 return evaluated

def _logistic ( x ) : x = np . array ( x ) if ( x . ndim == 0 ) : y = np . reshape ( x , ( 1 , 1 , 1 ) ) elif ( x . ndim == 1 ) : y = np . reshape ( x , ( len ( x ) , 1 , 1 ) ) elif ( x . ndim == 2 ) : y = np . reshape ( x , ( x . shape [ 0 ] , 1 , x . shape [ 1 ] ) ) elif ( x . ndim == 3 ) : y = x else : raise NotImplementedError tmp = np . c_ [ ( np . zeros ( ( y . shape [ ( - 1 ) ] , y . shape [ 1 ] , 1 ) ) , y . T ) ] . T evaluated = np . reshape ( np . exp ( ( y - logsumexp ( tmp , axis = 0 ) ) ) , x . shape ) return evaluated
note that this is not a vectorized function .