code: def setup_persistent_compute_target(
      workspace, cluster_name, vm_size, max_nodes
  ):
      """
      Set up a persistent compute target on AzureML.
      A persistent compute target runs noticeably faster than a
      regular compute target for subsequent runs.  The benefit
      is that AzureML manages turning the compute on/off as needed for
      each job so the user does not need to do this.
  
      Args:
          workspace    (str): Centralized location on Azure to work with
                           all the
                                  artifacts used by AzureML service
          cluster_name (str): the Azure cluster for this run. It can
                              already exist or it will be created.
          vm_size      (str): Azure VM size, like STANDARD_D3_V2
          max_nodes    (int): Number of VMs, max_nodes=4 will
                              autoscale up to 4 VMs
      Returns:
          cpu_cluster : cluster reference
      """
      # setting vmsize and num nodes creates a persistent AzureML
      # compute resource
  
      logger.debug("setup: cluster_name {}".format(cluster_name))
      # https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-set-up-training-targets
  
      try:
          cpu_cluster = ComputeTarget(
              workspace=workspace, name=cluster_name
          )
          logger.debug("setup: Found existing cluster, use it.")
      except ComputeTargetException:
          logger.debug("setup: create cluster")
          compute_config = AmlCompute.provisioning_configuration(
              vm_size=vm_size,
              max_nodes=max_nodes,
              ssh_public_access_enabled=True,
              idle_time_before_scale_down=3600,  # 1 hour
          )
          cpu_cluster = ComputeTarget.create(
              workspace, cluster_name, compute_config
          )
      cpu_cluster.wait_for_completion(show_output=False)
      return cpu_cluster
  
file_path: recommenders/tests/ci/azureml_tests/submit_groupwise_azureml_pytest.py
imports: import argparse
  import logging
  import glob
  from azureml.core.authentication import AzureCliAuthentication
  from azureml.core import Workspace
  from azureml.core import Experiment
  from azureml.core.runconfig import RunConfiguration
  from azureml.core.conda_dependencies import CondaDependencies
  from azureml.core.script_run_config import ScriptRunConfig
  from azureml.core.compute import ComputeTarget, AmlCompute
  from azureml.core.compute_target import ComputeTargetException
  from azureml.core.workspace import WorkspaceException
label_desc: Use image node_id 2 for calling a global function with example usage: setup_persistent_compute_target(workspace, cluster_name, vm_size, max_nodes) and returns: cpu_cluster