code: def preserve_global_rank_variable():
      """Ensures that the rank_zero_only.rank global variable gets reset in each test."""
      from lightning.fabric.utilities.rank_zero import (
          rank_zero_only as rank_zero_only_fabric,
      )
      from lightning_utilities.core.rank_zero import (
          rank_zero_only as rank_zero_only_utilities,
      )
  
      functions = (rank_zero_only_fabric, rank_zero_only_utilities)
      ranks = [getattr(fn, "rank", None) for fn in functions]
      yield
      for fn, rank in zip(functions, ranks):
          if rank is not None:
              setattr(fn, "rank", rank)
  
imports: import os
  import sys
  import threading
  from typing import List
  from unittest.mock import Mock
  import lightning.fabric
  import pytest
  import torch.distributed
  from lightning.fabric.accelerators import XLAAccelerator
  from lightning.fabric.strategies.launchers.subprocess_script import _ChildProcessObserver
  from lightning.fabric.utilities.distributed import _distributed_is_initialized
label_desc: Use image node_id 1 for calling a global function with example usage: preserve_global_rank_variable() without return types