stricter error checking for indexCopy

This makes sure that the source tensor for indexCopy will have exactly as many elements in dimension "dim" as the indices provided.

I'll leave this as an open PR for 24 hours for any objections.