The previous implementation would still crash if the element type was
not iterable. This patch changes SparseElementsAttr to properly
implement try_value_begin_impl according to ElementsAttr and changes
DenseElementsAttr to implement tryGetValues as the basis for querying
element values.
Depends on D132904