code: def teardown_tempdir(dir):
      r'''
      Cleanup temporary directory.
      '''
  
      if ssh_conn:
          delete_tree(dir)
  
      assert_valid_dir(dir)
      shutil.rmtree(dirf teardown_tempdir(dir):
      r'''
      Cleanup temporary directory.
      '''
  
      if ssh_conn:
          delete_tree(dir)
  
      assert_valid_dir(dir)
      shutil.rmtree(dir)
docs: r'''
      Cleanup temporary directory.