App Crashes when try to modified collectionViewLayout in iOS 10

I am getting below issue
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0x618000035a40> {length = 2, path = 0 - 5}'

i followed below link , even sample app from apple also crashing in IOS 10 when try to reload collectionView second time
https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/layouts/customizing_collection_view_layouts

App Crashes when try to modified collectionViewLayout in iOS 10
 
 
Q