code: def test_validate_user_settings():
      """Test that the environment can validate the number of devices and nodes set in Fabric/Trainer."""
      env = SLURMEnvironment()
      env.validate_settings(num_devices=4, num_nodes=2)
  
      with pytest.raises(
          ValueError,
          match="the number of tasks per node configured .* does not match",
      ):
          env.validate_settings(num_devices=2, num_nodes=2)
  
      with pytest.raises(
          ValueError,
          match="the number of nodes configured in SLURM .* does not match",
      ):
          env.validate_settings(num_devices=4, num_nodes=1)
  
      # in interactive mode, validation is skipped becauses processes get launched by Fabric/Trainer, not SLURM
      with mock.patch(
          "lightning.fabric.plugins.environments.slurm.SLURMEnvironment.job_name",
          return_value="interactive",
      ):
          env = SLURMEnvironment()
          env.validate_settings(num_devices=4, num_nodes=1)
  
file_path: pytorch-lightning/tests/tests_fabric/plugins/environments/test_slurm.py
imports: import logging
  import os
  import shutil
  import sys
  from unittest import mock
  import pytest
  from lightning.fabric.plugins.environments import SLURMEnvironment
  from lightning.fabric.utilities.warnings import PossibleUserWarning
  from lightning_utilities.test.warning import no_warning_call
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 8 for calling a global function with example usage: test_validate_user_settings() without return types