apply_axes function

Apply a function over specified array axes.