<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def phase_uniquizer(all_phases):
 """Makes the names of phase measurement and attachments unique. This function will make the names of measurements and attachments unique. It modifies the input all_phases. Args: all_phases: the phases to make unique Returns: the phases now modified. """

  measurement_name_maker = UniqueNameMaker(
      itertools.chain.from_iterable(
          phase.measurements.keys() for phase in all_phases
          if phase.measurements))
  attachment_names = list(itertools.chain.from_iterable(
      phase.attachments.keys() for phase in all_phases))
  attachment_names.extend(itertools.chain.from_iterable([
      'multidim_' + name for name, meas in phase.measurements.items()
      if meas.dimensions is not None
  ] for phase in all_phases if phase.measurements))
  attachment_name_maker = UniqueNameMaker(attachment_names)
  for phase in all_phases:
    # Make measurements unique.
    for name, _ in sorted(phase.measurements.items()):
      old_name = name
      name = measurement_name_maker.make_unique(name)

      phase.measurements[old_name].name = name
      phase.measurements[name] = phase.measurements.pop(old_name)
    # Make attachments unique.
    for name, _ in sorted(phase.attachments.items()):
      old_name = name
      name = attachment_name_maker.make_unique(name)
      phase.attachments[old_name].name = name
      phase.attachments[name] = phase.attachments.pop(old_name)
  return all_phases