docstr: :param mem_net_list: A list of world models used to simulate trajectories
  :param cem_num_iterations: The maximum number of iterations for
      searching the best action
  :param cem_population_size: The number of candidate solutions to
      evaluate in each CEM iteration
  :param ensemble_population_size: The number of trajectories to be
      sampled to evaluate a CEM solution
  :param num_elites: The number of elites kept to refine solutions
      in each iteration
  :param plan_horizon_length: The number of steps to plan ahead
  :param state_dim: state dimension
  :param action_dim: action dimension
  :param discrete_action: If actions are discrete or continuous
  :param terminal_effective: If False, planning will stop after a
      predicted terminal signal
  :param gamma: The reward discount factor
  :param alpha: The CEM solution update rate
  :param epsilon: The planning will stop early when the solution
      variance drops below epsilon
  :param action_upper_bounds: Upper bound of each action dimension.
      Only effective when discrete_action=False.
  :param action_lower_bounds: Lower bound of each action dimension.
      Only effective when discrete_action=False.
docstr_tok: [":","param","mem_net_list",":","A","list","of","world","models","used","to","simulate","trajectories",":","param","cem_num_iterations",":","The","maximum","number","of","iterations","for","searching","the","best","action",":","param","cem_population_size",":","The","number","of","candidate","solutions","to","evaluate","in","each","CEM","iteration",":","param","ensemble_population_size",":","The","number","of","trajectories","to","be","sampled","to","evaluate","a","CEM","solution",":","param","num_elites",":","The","number","of","elites","kept","to","refine","solutions","in","each","iteration",":","param","plan_horizon_length",":","The","number","of","steps","to","plan","ahead",":","param","state_dim",":","state","dimension",":","param","action_dim",":","action","dimension",":","param","discrete_action",":","If","actions","are","discrete","or","continuous",":","param","terminal_effective",":","If","False",",","planning","will","stop","after","a","predicted","terminal","signal",":","param","gamma",":","The","reward","discount","factor",":","param","alpha",":","The","CEM","solution","update","rate",":","param","epsilon",":","The","planning","will","stop","early","when","the","solution","variance","drops","below","epsilon",":","param","action_upper_bounds",":","Upper","bound","of","each","action","dimension",".","Only","effective","when","discrete_action=False",".",":","param","action_lower_bounds",":","Lower","bound","of","each","action","dimension",".","Only","effective","when","discrete_action=False","."]
code: def __init__(
      self,
      mem_net_list: List[MemoryNetwork],
      cem_num_iterations: int,
      cem_population_size: int,
      ensemble_population_size: int,
      num_elites: int,
      plan_horizon_length: int,
      state_dim: int,
      action_dim: int,
      discrete_action: bool,
      terminal_effective: bool,
      gamma: float,
      alpha: float = 0.25,
      epsilon: float = 0.001,
      action_upper_bounds: Optional[np.ndarray] = None,
      action_lower_bounds: Optional[np.ndarray] = None,
  ):
      """
      :param mem_net_list: A list of world models used to simulate trajectories
      :param cem_num_iterations: The maximum number of iterations for
          searching the best action
      :param cem_population_size: The number of candidate solutions to
          evaluate in each CEM iteration
      :param ensemble_population_size: The number of trajectories to be
          sampled to evaluate a CEM solution
      :param num_elites: The number of elites kept to refine solutions
          in each iteration
      :param plan_horizon_length: The number of steps to plan ahead
      :param state_dim: state dimension
      :param action_dim: action dimension
      :param discrete_action: If actions are discrete or continuous
      :param terminal_effective: If False, planning will stop after a
          predicted terminal signal
      :param gamma: The reward discount factor
      :param alpha: The CEM solution update rate
      :param epsilon: The planning will stop early when the solution
          variance drops below epsilon
      :param action_upper_bounds: Upper bound of each action dimension.
          Only effective when discrete_action=False.
      :param action_lower_bounds: Lower bound of each action dimension.
          Only effective when discrete_action=False.
      """
      super().__init__()
      self.mem_net_list = nn.ModuleList(mem_net_list)
      self.cem_num_iterations = cem_num_iterations
      self.cem_pop_size = cem_population_size
      self.ensemble_pop_size = ensemble_population_size
      self.num_elites = num_elites
      self.plan_horizon_length = plan_horizon_length
      self.state_dim = state_dim
      self.action_dim = action_dim
      self.terminal_effective = terminal_effective
      self.gamma = gamma
      self.alpha = alpha
      self.epsilon = epsilon
      self.discrete_action = discrete_action
      if not discrete_action:
          assert (
              (action_upper_bounds is not None)
              and (action_lower_bounds is not None)
              and (
                  action_upper_bounds.shape
                  == action_lower_bounds.shape
                  == (action_dim,)
              )
          )
          assert np.all(action_upper_bounds >= action_lower_bounds)
          self.action_upper_bounds = np.tile(
              action_upper_bounds, self.plan_horizon_length
          )
          self.action_lower_bounds = np.tile(
              action_lower_bounds, self.plan_horizon_length
          )
          self.orig_action_upper = torch.tensor(action_upper_bounds)
          self.orig_action_lower = torch.tensor(action_lower_bounds)
  
imports: import itertools
  import logging
  import random
  from typing import List, Optional, Tuple
  import numpy
  import scipy.stats
  import torch
  import torch.nn
  from reagent.core import types
  from reagent.core.parameters import CONTINUOUS_TRAINING_ACTION_RANGE
  from reagent.models.base import ModelBase
  from reagent.models.world_model import MemoryNetwork
  from reagent.training.utils import rescale_actions
  from torch.distributions.bernoulli import Bernoulli
  from torch.distributions.categorical import Categorical
  from torch.distributions.normal import Normal
label_desc: Use image node_id 1 to create a new CEMPlannerNetwork object from inherited base classes: nn with example: obj = CEMPlannerNetwork(mem_net_list, cem_num_iterations, cem_population_size, ensemble_population_size, num_elites, plan_horizon_length, state_dim, action_dim, discrete_action, terminal_effective, gamma, alpha, epsilon, action_upper_bounds, action_lower_bounds)