code: def test_n_samples(monkeypatch, space):
      """Test n_samples is used properly when sampling random points"""
      mock_train_regressor(monkeypatch)
  
      PARAMS = ["x", "z"]
      N_SAMPLES = numpy.random.randint(20, 50)
  
      def mock_partial_dependency_grid(
          space, model, params, samples, n_points
      ):
          assert samples.shape == (N_SAMPLES, len(space))
          return partial_dependency_grid(
              space, model, params, samples, n_points
          )
  
      monkeypatch.setattr(
          "orion.analysis.partial_dependency_utils.partial_dependency_grid",
          mock_partial_dependency_grid,
      )
  
      partial_dependency(
          data,
          space,
          params=PARAMS,
          n_grid_points=5,
          n_samples=N_SAMPLES,
      )
  
imports: import copy
  import numpy
  import pandas
  import pytest
  from orion.analysis.partial_dependency_utils import make_grid, partial_dependency, partial_dependency_grid, reverse
  from orion.core.io.space_builder import SpaceBuilder
  from orion.core.utils import format_trials
  from orion.core.worker.transformer import build_required_space
label_desc: Use image node_id 17 for calling a global function with example usage: test_n_samples(monkeypatch, space) and returns: partial_dependency_grid