PR #10395: Handle missing collective_permute in collective-permute-motion
PR #10395: Handle missing collective_permute in collective-permute-motion

Imported from GitHub PR https://github.com/openxla/xla/pull/10395

Currently, the `MoveCollectivePermutes` function expects that if `FindMovableClusterAtBodyRoot` function returns a cluster, then the cluster's `collective_permute` field is not null. However, if `FindMovableClusterAtBodyRoot` does not find a collective_permute on when traversing an input, it happily returns cluster with `collective_permute == null`. This patch just returns `nullopt` for a 'cluster' without collective-permute.

Fixes #10394.
Copybara import of the project:

--
bf69727505c62b0bba36ad28ddaad36f07f816e3 by Jaroslav Sevcik <jsevcik@nvidia.com>:

Handle missing collective_permute

Merging this change closes #10395

FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/openxla/xla/pull/10395 from jaro-sevcik:collective-permute-motion-fix bf69727505c62b0bba36ad28ddaad36f07f816e3
