code: def run(checkpoint_path, policy_id):
      # __sphinx_doc_begin__
      # Restore policy.
      policy = Policy.from_checkpoint(
          checkpoint=checkpoint_path,
          policy_ids=[policy_id],
      )
  
      # Run CartPole.
      env = gym.make("CartPole-v1")
      obs, info = env.reset()
      terminated = truncated = False
      step = 0
      while not terminated and not truncated:
          step += 1
  
          # Use local_policy_inference() to run inference, so we do not have to
          # provide policy states or extra fetch dictionaries.
          # "env_1" and "agent_1" are dummy env and agent IDs to run connectors with.
          policy_outputs = local_policy_inference(
              policy, "env_1", "agent_1", obs, explore=False
          )
          assert len(policy_outputs) == 1
          action, _, _ = policy_outputs[0]
          print(f"step {step}", obs, action)
  
          # Step environment forward one more step.
          obs, _, terminated, truncated, _ = env.step(action)
  
imports: import gymnasium
  import os
  import tempfile
  from ray.rllib.examples.connectors.prepare_checkpoint import create_appo_cartpole_checkpoint
  from ray.rllib.policy.policy import Policy
  from ray.rllib.utils.policy import local_policy_inference
label_desc: Use image node_id 1 for calling a global function with example usage: run(checkpoint_path, policy_id) without return types