code: def test_cancel_stops_background_thread(self) -> None:
      name = "PeriodicTimer_CancelStopsBackgroundThreadTest"
  
      timer = _PeriodicTimer(timedelta(seconds=1), lambda: None)
  
      timer.set_name(name)
  
      timer.start()
  
      self.assertTrue(
          any(t.name == name for t in threading.enumerate())
      )
  
      timer.cancel()
  
      self.assertTrue(
          all(t.name != name for t in threading.enumerate())
      )
  
imports: import threading
  import time
  import socket
  from datetime import timedelta
  from typing import List
  from unittest import TestCase
  from unittest.mock import patch
  from torch.distributed.elastic.rendezvous.utils import _PeriodicTimer, _delay, _matches_machine_hostname, _parse_rendezvous_config, _try_parse_port, parse_rendezvous_endpoint
label_desc: Use image node_id 3 for calling the PeriodicTimerTest obj's underlying member method code with example usage: obj.test_cancel_stops_background_thread() without return types