code: def test_ranks_available_manual_strategy_selection(_, strategy_cls):
      """Test that the rank information is readily available after Trainer initialization."""
      num_nodes = 2
      for cluster, variables, expected in environment_combinations():
          with mock.patch.dict(os.environ, variables):
              strategy = strategy_cls(
                  parallel_devices=[
                      torch.device("cuda", 1),
                      torch.device("cuda", 2),
                  ],
                  cluster_environment=cluster,
              )
              trainer = Trainer(strategy=strategy, num_nodes=num_nodes)
              assert rank_zero_only.rank == expected["global_rank"]
              assert trainer.global_rank == expected["global_rank"]
              assert trainer.local_rank == expected["local_rank"]
              assert trainer.node_rank == expected["node_rank"]
              assert trainer.world_size == expected["world_size"]
  
file_path: pytorch-lightning/tests/tests_pytorch/plugins/test_cluster_integration.py
imports: import os
  from unittest import mock
  import pytest
  import torch
  from lightning.fabric.plugins.environments import LightningEnvironment, SLURMEnvironment, TorchElasticEnvironment
  from lightning.pytorch import Trainer
  from lightning.pytorch.strategies import DDPStrategy, DeepSpeedStrategy
  from lightning.pytorch.utilities.rank_zero import rank_zero_only
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 2 for calling a global function with example usage: test_ranks_available_manual_strategy_selection(_, strategy_cls) without return types