code: def run(checkpoint_path, policy_id):
      # Restore policy.
      policy = Policy.from_checkpoint(
          checkpoint=checkpoint_path,
          policy_ids=[policy_id],
      )
  
      # Adapt policy trained for standard CartPole to the new env.
      ctx: ConnectorContext = ConnectorContext.from_policy(policy)
  
      # When this policy was trained, it relied on FlattenDataAgentConnector
      # to add a batch dimension to single observations.
      # This is not necessary anymore, so we first remove the previously used
      # FlattenDataAgentConnector.
      policy.agent_connectors.remove("FlattenDataAgentConnector")
  
      # We then add the two adapter connectors.
      policy.agent_connectors.prepend(V2ToV1ObsAgentConnector(ctx))
      policy.action_connectors.append(V1ToV2ActionConnector(ctx))
  
      # Run CartPole.
      env = MyCartPole()
      obs, info = env.reset()
      done = False
      step = 0
      while not done:
          step += 1
  
          # Use local_policy_inference() to easily run poicy with observations.
          policy_outputs = local_policy_inference(
              policy, "env_1", "agent_1", obs
          )
          assert len(policy_outputs) == 1
          actions, _, _ = policy_outputs[0]
          print(f"step {step}", obs, actions)
  
          obs, _, done, _, _ = env.step(actions)
  
imports: import gymnasium
  import numpy
  import os
  import tempfile
  from typing import Dict
  from ray.rllib.connectors.connector import ConnectorContext
  from ray.rllib.connectors.action.lambdas import register_lambda_action_connector
  from ray.rllib.connectors.agent.lambdas import register_lambda_agent_connector
  from ray.rllib.examples.connectors.prepare_checkpoint import create_appo_cartpole_checkpoint
  from ray.rllib.policy.policy import Policy
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.utils.policy import local_policy_inference
  from ray.rllib.utils.typing import PolicyOutputType, StateBatches, TensorStructType
label_desc: Use image node_id 3 for calling a global function with example usage: run(checkpoint_path, policy_id) without return types