code: def check_destroy_group():
      with mock.patch(
          "lightning.fabric.plugins.collectives.torch_collective.TorchCollective.new_group",
          wraps=TorchCollective.new_group,
      ) as mock_new, mock.patch(
          "lightning.fabric.plugins.collectives.torch_collective.TorchCollective.destroy_group",
          wraps=TorchCollective.destroy_group,
      ) as mock_destroy:
          yield
      # 0 to account for tests that mock distributed
      # -1 to account for destroying the default process group
      expected = (
          0 if mock_new.call_count == 0 else mock_destroy.call_count - 1
      )
      assert (
          mock_new.call_count == expected
      ), f"new_group={mock_new.call_count}, destroy_group={mock_destroy.call_count}"
      if TorchCollective.is_available():
          assert not torch.distributed.distributed_c10d._pg_map
          assert not TorchCollective.is_initialized()
  
imports: import contextlib
  import datetime
  import os
  from functools import partial
  from unittest import mock
  import pytest
  import torch
  from lightning.fabric.accelerators import CPUAccelerator, CUDAAccelerator
  from lightning.fabric.plugins.collectives import TorchCollective
  from lightning.fabric.plugins.environments import LightningEnvironment
  from lightning.fabric.strategies.ddp import DDPStrategy
  from lightning.fabric.strategies.launchers.multiprocessing import _MultiProcessingLauncher
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_1_13
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 1 for calling a global function with example usage: check_destroy_group() without return types