code: def run_test_online_episode(
      env: Env__Union,
      model: ModelManager__Union,
      num_train_episodes: int,
      passing_score_bar: float,
      num_eval_episodes: int,
      use_gpu: bool,
  ):
      """
      Run an online learning test. At the end of each episode training is run on the trajectory.
      """
      env = env.value
      pl.seed_everything(SEED)
      env.seed(SEED)
      env.action_space.seed(SEED)
  
      normalization = build_normalizer(env)
      logger.info(
          f"Normalization is: \n{pprint.pformat(normalization)}"
      )
  
      manager = model.value
      trainer = manager.build_trainer(
          use_gpu=use_gpu,
          normalization_data_map=normalization,
      )
      policy = manager.create_policy(trainer, serving=False)
  
      device = torch.device("cuda") if use_gpu else torch.device("cpu")
  
      agent = Agent.create_for_env(env, policy, device=device)
  
      torch.use_deterministic_algorithms(True, warn_only=True)
      pl_trainer = pl.Trainer(
          max_epochs=1,
          gpus=int(use_gpu),
          default_root_dir=f"lightning_log_{str(uuid.uuid4())}",
      )
      dataset = EpisodicDataset(
          env=env,
          agent=agent,
          num_episodes=num_train_episodes,
          seed=SEED,
      )
      data_loader = torch.utils.data.DataLoader(
          dataset, collate_fn=identity_collate
      )
      pl_trainer.fit(trainer, data_loader)
  
      eval_rewards = evaluate_for_n_episodes(
          n=num_eval_episodes,
          env=env,
          agent=agent,
          max_steps=env.max_steps,
          num_processes=1,
      ).squeeze(1)
      assert (
          eval_rewards.mean() >= passing_score_bar
      ), f"Eval reward is {eval_rewards.mean()}, less than < {passing_score_bar}.\n"
  
imports: import logging
  import os
  import pprint
  import unittest
  import uuid
  from typing import Optional
  import numpy
  import pytest
  import pytorch_lightning
  import torch
  from parameterized import parameterized
  from reagent.gym.agents.agent import Agent
  from reagent.gym.datasets.episodic_dataset import EpisodicDataset
  from reagent.gym.datasets.replay_buffer_dataset import ReplayBufferDataset
  from reagent.gym.envs import Env__Union
  from reagent.gym.envs.env_wrapper import EnvWrapper
  from reagent.gym.policies.policy import Policy
  from reagent.gym.policies.random_policies import make_random_policy_for_env
  from reagent.gym.runners.gymrunner import evaluate_for_n_episodes
  from reagent.gym.utils import build_normalizer, fill_replay_buffer
  from reagent.model_managers.union import ModelManager__Union
  from reagent.replay_memory.circular_replay_buffer import ReplayBuffer
  from reagent.test.base.horizon_test_base import HorizonTestBase
label_desc: Use image node_id 4 for calling a global function with example usage: run_test_online_episode(env, model, num_train_episodes, passing_score_bar, num_eval_episodes, use_gpu) without return types