code: def test_writing_stack(self) -> None:
      with TemporaryDirectory() as tmp_dir1, TemporaryDirectory() as tmp_dir2:
          writer1 = SummaryWriter(tmp_dir1)
          writer1.add_scalar = MagicMock()
          writer2 = SummaryWriter(tmp_dir2)
          writer2.add_scalar = MagicMock()
          with summary_writer_context(writer1):
              with summary_writer_context(writer2):
                  SummaryWriterContext.add_scalar(
                      "test2", torch.ones(1)
                  )
              SummaryWriterContext.add_scalar("test1", torch.zeros(1))
          writer1.add_scalar.assert_called_once_with(
              "test1", torch.zeros(1), global_step=0
          )
          writer2.add_scalar.assert_called_once_with(
              "test2", torch.ones(1), global_step=0
          )
  
file_path: ReAgent/reagent/test/base/test_tensorboardX.py
imports: import unittest
  from tempfile import TemporaryDirectory
  from unittest.mock import call, MagicMock
  import torch
  from reagent.core.tensorboardX import summary_writer_context, SummaryWriterContext
  from reagent.test.base.horizon_test_base import HorizonTestBase
  from torch.utils.tensorboard import SummaryWriter
label_desc: Use image node_id 4 for calling the TestSummaryWriterContext obj's underlying member method code with example usage: obj.test_writing_stack() without return types