class_docstr: Base class for actor critic trainers. Suitable for multi-step and multi-agent training.
  
  :param algorithm_config: Algorithm parameters.
  :param rollout_generator: The rollout generator to use. This object encapsulates the env.
  :param evaluator: The evaluator to use.
  :param model: Structured torch actor critic model.
  :param model_selection: Optional model selection class, receives model evaluation results.
code: def __init__(
      self,
      algorithm_config: Union[
          A2CAlgorithmConfig, PPOAlgorithmConfig, ImpalaAlgorithmConfig
      ],
      rollout_generator: Union[RolloutGenerator, DistributedActors],
      evaluator: Optional[RolloutEvaluator],
      model: TorchActorCritic,
      model_selection: Optional[BestModelSelection],
  ):
      super().__init__(algorithm_config)
  
      # initialize policies and critic
      self.model = model
      self.model.to(self.algorithm_config.device)
  
      # initialize rollout generator
      self.rollout_generator = rollout_generator
  
      # initialize optimizer
      self.optimizer = torch.optim.Adam(
          self.model.parameters(), lr=self.algorithm_config.lr
      )
  
      # inject statistics directly into the epoch log
      epoch_stats = self.rollout_generator.get_epoch_stats_aggregator()
      self.ac_events = epoch_stats.create_event_topic(ActorCriticEvents)
  
      # other components
      self.model_selection = model_selection
      self.evaluator = evaluator
  
      if self.algorithm_config.n_epochs <= 0:
          self.algorithm_config.n_epochs = sys.maxsize
  
imports: import sys
  import time
  from abc import ABC, abstractmethod
  from typing import List, Union, Dict, Optional
  import numpy
  import torch
  import torch.nn
  from maze.core.agent.torch_actor_critic import TorchActorCritic
  from maze.core.annotations import override
  from maze.core.env.base_env_events import BaseEnvEvents
  from maze.core.env.structured_env import ActorID
  from maze.core.log_stats.log_stats import increment_log_step, LogStatsLevel
  from maze.core.rollout.rollout_generator import RolloutGenerator
  from maze.core.trajectory_recording.records.structured_spaces_record import StructuredSpacesRecord
  from maze.train.parallelization.distributed_actors.distributed_actors import DistributedActors
  from maze.train.trainers.a2c.a2c_algorithm_config import A2CAlgorithmConfig
  from maze.train.trainers.common.actor_critic.actor_critic_events import ActorCriticEvents
  from maze.train.trainers.common.evaluators.rollout_evaluator import RolloutEvaluator
  from maze.train.trainers.common.model_selection.best_model_selection import BestModelSelection
  from maze.train.trainers.common.trainer import Trainer
  from maze.train.trainers.impala.impala_algorithm_config import ImpalaAlgorithmConfig
  from maze.train.trainers.ppo.ppo_algorithm_config import PPOAlgorithmConfig
  from maze.train.utils.train_utils import compute_gradient_norm
  from maze.utils.bcolors import BColors
  from tqdm import tqdm
  from typing.io import BinaryIO
label_desc: Use image node_id 1 to create a new ActorCritic object from inherited base classes: Trainer, ABC with example: obj = ActorCritic(algorithm_config, rollout_generator, evaluator, model, model_selection)