Attaches the progress bar to an engine object.

        Args:
            engine (Engine): engine object.
            metric_names (list, optional): list of the metrics names to log as the bar progresses
            output_transform (callable, optional): a function to select what you want to print from the engine's
                output. This function may return either a dictionary with entries in the format of ``{name: value}``,
                or a single scalar, which will be displayed with the default name `output`.
            event_name: event's name on which the progress bar advances. Valid events are from
                :class:`~ignite.engine.Events`.
            closing_event_name: event's name on which the progress bar is closed. Valid events are from
                :class:`~ignite.engine.Events`.

def attach(self, engine, metric_names=None, output_transform=None,
               event_name=Events.ITERATION_COMPLETED,
               closing_event_name=Events.EPOCH_COMPLETED):
        """
        Attaches the progress bar to an engine object.

        Args:
            engine (Engine): engine object.
            metric_names (list, optional): list of the metrics names to log as the bar progresses
            output_transform (callable, optional): a function to select what you want to print from the engine's
                output. This function may return either a dictionary with entries in the format of ``{name: value}``,
                or a single scalar, which will be displayed with the default name `output`.
            event_name: event's name on which the progress bar advances. Valid events are from
                :class:`~ignite.engine.Events`.
            closing_event_name: event's name on which the progress bar is closed. Valid events are from
                :class:`~ignite.engine.Events`.
        """
        desc = self.tqdm_kwargs.get("desc", "Epoch")

        if not (event_name in Events and closing_event_name in Events):
            raise ValueError("Logging and closing events should be only ignite.engine.Events")

        if not self._compare_lt(event_name, closing_event_name):
            raise ValueError("Logging event {} should be called before closing event {}"
                             .format(event_name, closing_event_name))

        log_handler = _OutputHandler(desc, metric_names, output_transform,
                                     event_name=event_name,
                                     closing_event_name=closing_event_name)
        super(ProgressBar, self).attach(engine, log_handler, event_name)
        engine.add_event_handler(closing_event_name, self._close)