code: def _run_hyperopt_run_hyperopt(
      csv_filename, search_space, tmpdir, backend, ray_cluster_7cpu
  ):
      input_features = [category_feature(encoder={"vocab_size": 3})]
      output_features = [category_feature(decoder={"vocab_size": 3})]
  
      rel_path = generate_data(
          input_features, output_features, csv_filename
      )
  
      config = {
          INPUT_FEATURES: input_features,
          OUTPUT_FEATURES: output_features,
          COMBINER: {TYPE: "concat"},
          TRAINER: {
              "epochs": 2,
              "learning_rate": 0.001,
              BATCH_SIZE: 128,
          },
          "backend": backend,
      }
  
      output_feature_name = output_features[0][NAME]
  
      if search_space == "random":
          # random search will be size of num_samples
          search_parameters = {
              "trainer.learning_rate": {
                  "lower": 0.0001,
                  "upper": 0.01,
                  "space": "loguniform",
              },
              output_feature_name
              + ".decoder.fc_layers": {
                  "space": "choice",
                  "categories": [
                      [{"output_size": 64}, {"output_size": 32}],
                      [{"output_size": 64}],
                      [{"output_size": 32}],
                  ],
              },
              output_feature_name
              + ".decoder.fc_output_size": {
                  "space": "choice",
                  "categories": [16, 21, 26, 31, 36],
              },
          }
      else:
          # grid search space will be product each parameter size
          search_parameters = {
              "trainer.learning_rate": {
                  "space": "grid_search",
                  "values": [0.001, 0.01],
              },
              output_feature_name
              + ".decoder.fc_output_size": {
                  "space": "grid_search",
                  "values": [16, 21],
              },
          }
  
      hyperopt_configs = {
          "parameters": search_parameters,
          "goal": "minimize",
          "output_feature": output_feature_name,
          "validation_metrics": "loss",
          "executor": {
              TYPE: "ray",
              "num_samples": 1
              if search_space == "grid"
              else RANDOM_SEARCH_SIZE,
              "max_concurrent_trials": 1,
          },
          "search_alg": {TYPE: "variant_generator"},
      }
  
      # add hyperopt parameter space to the config
      config[HYPEROPT] = hyperopt_configs
  
      experiment_name = f"test_hyperopt_{uuid.uuid4().hex}"
      hyperopt_results = hyperopt(
          config,
          dataset=rel_path,
          output_directory=tmpdir,
          experiment_name=experiment_name,
      )
      if search_space == "random":
          assert (
              hyperopt_results.experiment_analysis.results_df.shape[0]
              == RANDOM_SEARCH_SIZE
          )
      else:
          # compute size of search space for grid search
          grid_search_size = 1
          for k, v in search_parameters.items():
              grid_search_size *= len(v["values"])
          assert (
              hyperopt_results.experiment_analysis.results_df.shape[0]
              == grid_search_size
          )
  
      # check for return results
      assert isinstance(hyperopt_results, HyperoptResults)
  
      # check for existence of the hyperopt statistics file
      with use_credentials(minio_test_creds()):
          assert fs_utils.path_exists(
              os.path.join(
                  tmpdir, experiment_name, HYPEROPT_STATISTICS_FILE_NAME
              )
          )
          for trial in hyperopt_results.experiment_analysis.trials:
              assert fs_utils.path_exists(
                  os.path.join(
                      tmpdir, experiment_name, f"trial_{trial.trial_id}"
                  ),
              )
  
      with RayTuneExecutor._get_best_model_path(
          hyperopt_results.experiment_analysis.best_trial,
          hyperopt_results.experiment_analysis,
          minio_test_creds(),
      ) as path:
          assert path is not None
          assert isinstance(path, str)
          assert "model" in os.listdir(path)
  
imports: import json
  import os
  import os.path
  import uuid
  from typing import Dict, Tuple
  import pytest
  from ludwig.backend import initialize_backend
  from ludwig.constants import ACCURACY, AUTO, BATCH_SIZE, CATEGORY, COMBINER, EXECUTOR, HYPEROPT, INPUT_FEATURES, MAX_CONCURRENT_TRIALS, MODEL_ECD, MODEL_GBM, MODEL_TYPE, NAME, OUTPUT_FEATURES, RAY, TEST, TEXT, TRAINER, TRAINING, TYPE, VALIDATION
  from ludwig.globals import HYPEROPT_STATISTICS_FILE_NAME
  from ludwig.hyperopt.results import HyperoptResults
  from ludwig.hyperopt.run import hyperopt
  from ludwig.hyperopt.utils import update_hyperopt_params_with_defaults
  from ludwig.schema.model_config import ModelConfig
  from ludwig.utils import fs_utils
  from ludwig.utils.data_utils import load_json, use_credentials
  from tests.integration_tests.utils import category_feature, generate_data, minio_test_creds, private_param, remote_tmpdir, text_feature
  from ludwig.hyperopt.execution import get_build_hyperopt_executor, RayTuneExecutor
label_desc: Use image node_id 6 for calling a global function with example usage: _run_hyperopt_run_hyperopt(csv_filename, search_space, tmpdir, backend, ray_cluster_7cpu) without return types