BUG make take_nd support readonly arrays
This is a tentative fix for #10043. I have not run any benchmark yet. I think we should do that before considering merging this PR. Any recommended way to do it?
