class_docstr: Multi step advantage actor critic.
      
docstr: Train function that wraps normal train function in order to close all processes properly
  
  :param n_epochs: number of epochs to train.
docstr_tok: ["Train","function","that","wraps","normal","train","function","in","order","to","close","all","processes","properly",":","param","n_epochs",":","number","of","epochs","to","train","."]
code: def train(self, n_epochs: Optional[int] = None) -> None:
      """Train function that wraps normal train function in order to close all processes properly
  
      :param n_epochs: number of epochs to train.
      """
  
      try:
          self.rollout_generator.broadcast_updated_policy(
              self.model.state_dict()
          )
          self.rollout_generator.start()
          super().train(n_epochs)
          self.rollout_generator.stop()
      except Exception as e:
          print("caught exception")
          self.rollout_generator.stop()
          raise e
  
imports: import time
  from collections import defaultdict
  from typing import Optional
  import torch
  from maze.core.agent.torch_actor_critic import TorchActorCritic
  from maze.core.annotations import override
  from maze.core.trajectory_recording.records.structured_spaces_record import StructuredSpacesRecord
  from maze.perception.perception_utils import map_nested_structure
  from maze.train.parallelization.distributed_actors.distributed_actors import DistributedActors
  from maze.train.trainers.common.actor_critic.actor_critic_trainer import ActorCritic
  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 import impala_vtrace
  from maze.train.trainers.impala.impala_algorithm_config import ImpalaAlgorithmConfig
  from maze.train.trainers.impala.impala_events import ImpalaEvents
label_desc: Use image node_id 2 for calling the IMPALA obj's underlying member method code with example usage: obj.train(n_epochs) without return types