code: def run_inference(
      test_experiment,
      compute_target,
      script_folder,
      train_run,
      test_dataset,
      target_column_name,
      model_name,
  ):
      try:
          inference_env = train_run.get_environment()
      except BaseException:
          run_details = train_run.get_details()
          run_def = run_details.get("runDefinition")
          env = run_def.get("environment")
          if env is None:
              raise
          json.dump(env, open("azureml_environment.json", "w"))
          inference_env = Environment.load_from_directory(".")
  
      est = ScriptRunConfig(
          source_directory=script_folder,
          script="infer.py",
          arguments=[
              "--target_column_name",
              target_column_name,
              "--model_name",
              model_name,
              "--input-data",
              test_dataset.as_named_input("data"),
          ],
          compute_target=compute_target,
          environment=inference_env,
      )
  
      run = test_experiment.submit(
          est,
          tags={
              "training_run_id": train_run.id,
              "run_algorithm": train_run.properties["run_algorithm"],
              "valid_score": train_run.properties["score"],
              "primary_metric": train_run.properties["primary_metric"],
          },
      )
  
      run.log("run_algorithm", run.tags["run_algorithm"])
      return run
  
imports: import json
  import pandas
  from azureml.core import Environment, ScriptRunConfig
  from azureml.core.run import Run
label_desc: Use image node_id 1 for calling a global function with example usage: run_inference(test_experiment, compute_target, script_folder, train_run, test_dataset, target_column_name, model_name) and returns: run