<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def configure_and_build(self, show_progress=True, optimized=True, skip_configuration=False):
 """ Configure and build the ns-3 code. Args: show_progress (bool):
 whether or not to display a progress bar during compilation. optimized (bool):
 whether to use an optimized build. If False, use a standard ./waf configure. skip_configuration (bool):
 whether to skip the configuration step, and only perform compilation. """


        # Only configure if necessary
        if not skip_configuration:
            configuration_command = ['python', 'waf', 'configure', '--enable-examples',
                                     '--disable-gtk', '--disable-python']

            if optimized:
                configuration_command += ['--build-profile=optimized',
                                          '--out=build/optimized']

            # Check whether path points to a valid installation
            subprocess.call(configuration_command, cwd=self.path,
                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        # Build ns-3
        build_process = subprocess.Popen(['python', 'waf', 'build'], cwd=self.path,
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE)

        # Show a progress bar
        if show_progress:
            line_iterator = self.get_build_output(build_process)
            pbar = None
            try:
                [initial, total] = next(line_iterator)
                pbar = tqdm(line_iterator, initial=initial, total=total,
                            unit='file', desc='Building ns-3', smoothing=0)
                for current, total in pbar:
                    pbar.n = current
            except (StopIteration):
                if pbar is not None:
                    pbar.n = pbar.total
        else:  # Wait for the build to finish anyway
            build_process.communicate()