code: def test_create_node_cap_at_max(
      attempted_target_replica_count, expected_target_replica_count
  ):
      """Validates that KubeRayNodeProvider does not attempt to create more nodes than
      allowed by maxReplicas. For the config in this test, maxReplicas is fixed at 300.
  
      Args:
          attempted_target_replica_count: The mocked desired replica count for a given
              worker group.
          expected_target_replica_count: The actual requested replicaCount. Should be
              capped at maxReplicas (300, for the config in this test.)
      """
      raycluster = get_basic_ray_cr()
      with mock.patch.object(
          KubeRayNodeProvider, "__init__", return_value=None
      ):
          kr_node_provider = KubeRayNodeProvider(
              provider_config={}, cluster_name="fake"
          )
          scale_request = ScaleRequest(
              workers_to_delete=set(),
              desired_num_workers={
                  "small-group": attempted_target_replica_count
              },
          )
          patch = kr_node_provider._scale_request_to_patch_payload(
              scale_request=scale_request, raycluster=raycluster
          )
          assert patch[0]["value"] == expected_target_replica_count
  
imports: import copy
  import mock
  import sys
  import jsonpatch
  import pytest
  from ray.autoscaler.batching_node_provider import NodeData
  from ray.autoscaler._private.kuberay.node_provider import _worker_group_index, _worker_group_max_replicas, _worker_group_replicas, KubeRayNodeProvider, ScaleRequest
  from ray.autoscaler._private.util import NodeID
  from pathlib import Path
  import yaml
  from ray.tests.kuberay.test_autoscaling_config import get_basic_ray_cr
  from typing import Set, List
label_desc: Use image node_id 5 for calling a global function with example usage: test_create_node_cap_at_max(attempted_target_replica_count, expected_target_replica_count) without return types