message: Fix crash from use of iterator after invalidation in grappler MutableGraphView
diff: @@ -639,6 +639,9 @@ Status MutableGraphView::SwapNodeNames(absl::string_view from_node_name,
  swap_names();
  // Swap controlling fanouts.
  + //
  + // Note: To and from control fanout iterators are still valid as no mutations
  + // has been performed on fanouts().
  SwapFanoutsMapValues(&fanouts(), from_control, from_control_fanouts,
  to_control, to_control_fanouts);
  @@ -706,6 +709,9 @@ Status MutableGraphView::SwapNodeNames(absl::string_view from_node_name,
  if (to_is_switch) {
  dedup_switch_control(from_node);
  } else {
  + // Fetch iterator again as the original iterator might have been
  + // invalidated by container rehash triggered due to mutations.
  + auto from_control_fanouts = fanouts().find(from_control);
  dedup_control_fanouts(from_node, from_control_fanouts);
  }
  }
  @@ -713,6 +719,9 @@ Status MutableGraphView::SwapNodeNames(absl::string_view from_node_name,
  if (from_is_switch) {
  dedup_switch_control(to_node);
  } else {
  + // Fetch iterator again as the original iterator might have been
  + // invalidated by container rehash triggered due to mutations.
  + auto to_control_fanouts = fanouts().find(to_control);
  dedup_control_fanouts(to_node, to_control_fanouts);
  }
  }
  