<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(self):
 """ Write result to the file. The output file is specified by ``file``. """

        writer = csv.writer(self.file)

        for f, b in zip(self.gb.result["forward"], self.gb.result["backward"]):
            f = f._asdict()
            b = b._asdict()
            if not self.check_same(f, b):
                raise AssertionError()

            args_info = ", ".join(["{}: {}".format(k, v)
                                   for k, v in f["args_info"]])

            out = [f["parameter_scope"], f["function_name"], f["inputs_shape"], args_info,
                   f["mean_time"], b["mean_time"], f["n_run"], b["n_run"]]

            writer.writerow(out)

        writer.writerow([])
        writer.writerow(["forward all", self.gb.result["forward_all"]])
        writer.writerow(
            ["forward_all_n_run", self.gb.result["n_run_forward_all"]])

        writer.writerow([])
        writer.writerow(["backward all", self.gb.result["backward_all"]])
        writer.writerow(
            ["backward_all_n_run", self.gb.result["n_run_backward_all"]])

        if set(self.gb.result.keys()) >= {"training", "n_run_training"}:
            writer.writerow([])
            writer.writerow(
                ["training(forward + backward + update)", self.gb.result["training"]])
            writer.writerow(
                ["training_n_run", self.gb.result["n_run_training"]])