code: def test_get_trainer_kwargs(
      trainer_config, cluster_resources, num_nodes, expected_kwargs
  ):
      with patch(
          "ludwig.backend.ray.ray.cluster_resources",
          return_value=cluster_resources,
      ):
          with patch(
              "ludwig.backend.ray._num_nodes", return_value=num_nodes
          ):
              trainer_config_copy = copy.deepcopy(trainer_config)
              actual_kwargs = get_trainer_kwargs(**trainer_config_copy)
  
              # Function should not modify the original input
              assert trainer_config_copy == trainer_config
  
              actual_backend = actual_kwargs.pop("backend")
              expected_backend = expected_kwargs.pop("backend")
  
              assert type(actual_backend) == type(expected_backend)
              if isinstance(actual_backend, HorovodConfig):
                  assert actual_backend.nics == expected_backend.nics
              assert actual_kwargs == expected_kwargs
  
file_path: ludwig/tests/ludwig/backend/test_ray.py
imports: import copy
  from unittest.mock import patch
  import pytest
  from ray.train.horovod import HorovodConfig
  from ray.train.torch import TorchConfig
  from ludwig.backend import initialize_backend
  from ludwig.backend.ray import get_trainer_kwargs
  from ludwig.constants import AUTO, EXECUTOR, MAX_CONCURRENT_TRIALS, RAY
label_desc: Use image node_id 1 for calling a global function with example usage: test_get_trainer_kwargs(trainer_config, cluster_resources, num_nodes, expected_kwargs) without return types