code: def test_torch_env_vars(ray_start_4_cpus):
      """Check that env vars are set as expected."""
  
      def train_func(config):
          context = train.get_context()
          assert os.environ["LOCAL_RANK"] == str(
              context.get_local_rank()
          )
          assert os.environ["RANK"] == str(context.get_world_rank())
          assert os.environ["LOCAL_WORLD_SIZE"] == str(
              context.get_local_world_size()
          )
          assert os.environ["WORLD_SIZE"] == str(
              context.get_world_size()
          )
          assert os.environ["NODE_RANK"] == str(context.get_node_rank())
  
          assert os.environ["ACCELERATE_TORCH_DEVICE"] == str(
              train.torch.get_device()
          )
  
      num_workers = 1
      scaling_config = ScalingConfig(num_workers=num_workers)
      trainer = TorchTrainer(
          train_loop_per_worker=train_func,
          scaling_config=scaling_config,
      )
      trainer.fit()
  
imports: import contextlib
  import os
  import tempfile
  import time
  import uuid
  from unittest.mock import patch
  import pytest
  import torch
  import ray
  import ray.train
  from ray.cluster_utils import Cluster
  from ray.train import Checkpoint, RunConfig, ScalingConfig
  from ray.train.examples.pytorch.torch_linear_example import train_func
  from ray.train.torch import TorchCheckpoint, TorchConfig, TorchPredictor, TorchTrainer
  from ray.train.trainer import TrainingFailedError
label_desc: Use image node_id 13 for calling a global function with example usage: test_torch_env_vars(ray_start_4_cpus) without return types