Optimize preprocess for ragged batching (#4942)
This PR improves efficiency of preprocessing for ragged batching.
It is not efficient to iterate substituting values to tensor slices or
copy/fill calls for small numbers of values. This PR records the values
in python lists or primitives and copy them at once.
---------
Co-authored-by: Michael Wyatt <michaelwyatt@microsoft.com>