def expand_dims(a, axis):
 shape = a.shape
 if (axis < 0):
  axis = ((axis + len(shape)) + 1)
 return a.reshape(((shape[:axis] + (1,)) + shape[axis:]))

def expand_dims ( a , axis ) : shape = a . shape if ( axis < 0 ) : axis = ( ( axis + len ( shape ) ) + 1 ) return a . reshape ( ( ( shape [ : axis ] + ( 1 , ) ) + shape [ axis : ] ) )
adds a 1-sized dimension at index "dim" .