class_docstr: Implementation of the model-based DreamerV3 RL algorithm described in [1].
class_docstr_tok: ["Implementation","of","the","model-based","DreamerV3","RL","algorithm","described","in","[","1","]","."]
code: def setup(self, config: AlgorithmConfig):
      super().setup(config)
  
      # Share RLModule between EnvRunner and single (local) Learner instance.
      # To avoid possibly expensive weight synching step.
      if self.config.share_module_between_env_runner_and_learner:
          assert self.workers.local_worker().module is None
          self.workers.local_worker().module = (
              self.learner_group._learner.module[DEFAULT_POLICY_ID]
          )
  
      # Summarize (single-agent) RLModule (only once) here.
      if self.config.framework_str == "tf2":
          self.workers.local_worker().module.dreamer_model.summary(
              expand_nested=True
          )
  
      # Create a replay buffer for storing actual env samples.
      self.replay_buffer = EpisodeReplayBuffer(
          capacity=self.config.replay_buffer_config["capacity"],
          batch_size_B=self.config.batch_size_B,
          batch_length_T=self.config.batch_length_T,
      )
  
imports: import copy
  import gc
  import logging
  import tree
  from typing import Any, Dict, List, Optional, Union
  import gymnasium
  import numpy
  from ray.rllib.algorithms.algorithm import Algorithm
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided
  from ray.rllib.algorithms.dreamerv3.dreamerv3_catalog import DreamerV3Catalog
  from ray.rllib.algorithms.dreamerv3.utils import do_symlog_obs
  from ray.rllib.algorithms.dreamerv3.utils.env_runner import DreamerV3EnvRunner
  from ray.rllib.algorithms.dreamerv3.utils.summaries import report_predicted_vs_sampled_obs, report_sampling_and_replay_buffer
  from ray.rllib.core.rl_module.rl_module import SingleAgentRLModuleSpec
  from ray.rllib.models.catalog import MODEL_DEFAULTS
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID, SampleBatch
  from ray.rllib.utils import deep_update
  from ray.rllib.utils.annotations import override, PublicAPI
  from ray.rllib.utils.framework import try_import_tf
  from ray.rllib.utils.numpy import one_hot
  from ray.rllib.utils.metrics import ALL_MODULES, GARBAGE_COLLECTION_TIMER, LEARN_ON_BATCH_TIMER, NUM_AGENT_STEPS_SAMPLED, NUM_AGENT_STEPS_TRAINED, NUM_ENV_STEPS_SAMPLED, NUM_ENV_STEPS_TRAINED, NUM_GRAD_UPDATES_LIFETIME, NUM_SYNCH_WORKER_WEIGHTS, NUM_TRAINING_STEP_CALLS_SINCE_LAST_SYNCH_WORKER_WEIGHTS, SAMPLE_TIMER, SYNCH_WORKER_WEIGHTS_TIMER
  from ray.rllib.utils.replay_buffers.episode_replay_buffer import EpisodeReplayBuffer
  from ray.rllib.utils.typing import LearningRateOrSchedule, ResultDict
label_desc: Use image node_id 3 for calling the DreamerV3 obj's underlying member method code with example usage: obj.setup(config) without return types