Write a function to optimize the layout of a complex collection view based on varying cell heights at xAI.