def _dot0(a, b):
 if (b.ndim <= 2):
  return dot(a, b)
 else:
  axes = list(range(b.ndim))
  axes.insert((-1), 0)
  axes.pop(0)
  return dot(a, b.transpose(axes))

def _dot0 ( a , b ) : if ( b . ndim <= 2 ) : return dot ( a , b ) else : axes = list ( range ( b . ndim ) ) axes . insert ( ( - 1 ) , 0 ) axes . pop ( 0 ) return dot ( a , b . transpose ( axes ) )
similar to numpy .