<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def solve_sweep_wavelength( self, structure, wavelengths, filename="wavelength_n_effs.dat", plot=True, ):
 """ Solve for the effective indices of a fixed structure at different wavelengths. Args: structure (Slabs):
 The target structure to solve for modes. wavelengths (list):
 A list of wavelengths to sweep over. filename (str):
 The nominal filename to use when saving the effective indices. Defaults to 'wavelength_n_effs.dat'. plot (bool):
 `True` if plots should be generates, otherwise `False`. Default is `True`. Returns: list: A list of the effective indices found for each wavelength. """

        n_effs = []
        for w in tqdm.tqdm(wavelengths, ncols=70):
            structure.change_wavelength(w)
            self.solve(structure)
            n_effs.append(np.real(self.n_effs))

        if filename:
            self._write_n_effs_to_file(
                n_effs, self._modes_directory + filename, wavelengths
            )
            if plot:
                if MPL:
                    title = "$n_{eff}$ vs Wavelength"
                    y_label = "$n_{eff}$"
                else:
                    title = "n_{effs} vs Wavelength" % x_label
                    y_label = "n_{eff}"
                self._plot_n_effs(
                    self._modes_directory + filename,
                    self._modes_directory + "fraction_te.dat",
                    "Wavelength",
                    "n_{eff}",
                    title,
                )

        return n_effs