code: def run_sampling(self):
      actor = Actor(self.args)
      while True:
          start = time.time()
          weights = None
          with self.model_lock:
              weights = self.agent.get_weights()
  
          random_action = False
          if self.rpm.size() < WARMUP_STEPS:
              random_action = True
  
          sample_data, episode_steps, episode_reward = actor.sample(
              weights, random_action
          )
  
          # Store data in replay memory
          with self.rpm_lock:
              for data in sample_data:
                  self.rpm.append(*data)
  
          sample_time = time.time() - start
          start = time.time()
  
          critic_loss, actor_loss = None, None
          # Train agent after collecting sufficient data
          if self.rpm.size() >= WARMUP_STEPS:
              for _ in range(len(sample_data)):
                  with self.rpm_lock:
                      (
                          batch_obs,
                          batch_action,
                          batch_reward,
                          batch_next_obs,
                          batch_terminal,
                      ) = self.rpm.sample_batch(BATCH_SIZE)
                  with self.model_lock:
                      critic_loss, actor_loss = self.agent.learn(
                          batch_obs,
                          batch_action,
                          batch_reward,
                          batch_next_obs,
                          batch_terminal,
                      )
          learn_time = time.time() - start
  
          mean_action = np.mean(
              np.array([x[1] for x in sample_data]), axis=0
          )
  
          with self.log_lock:
              self.total_steps += episode_steps
              self.total_MDP_steps += len(sample_data)
              summary.add_scalar(
                  "train/episode_reward",
                  episode_reward,
                  self.total_steps,
              )
              summary.add_scalar(
                  "train/episode_steps", episode_steps, self.total_steps
              )
              if critic_loss is not None:
                  summary.add_scalar(
                      "train/critic_loss", critic_loss, self.total_steps
                  )
                  summary.add_scalar(
                      "train/actor_loss", actor_loss, self.total_steps
                  )
              logger.info(
                  "Total Steps: {} Reward: {} Steps: {}".format(
                      self.total_steps, episode_reward, episode_steps
                  )
              )
  
              if (
                  self.total_steps // self.args.save_every_steps
                  >= self.save_cnt
              ):
                  while (
                      self.total_steps // self.args.save_every_steps
                      >= self.save_cnt
                  ):
                      self.save_cnt += 1
                  with self.model_lock:
                      self.agent.save(
                          os.path.join(
                              self.args.save_dir,
                              "model-{}".format(self.total_steps),
                          )
                      )
  
imports: import os
  import numpy
  import argparse
  import threading
  import time
  import parl
  from parl.utils import logger, summary, ReplayMemory
  from grid_model import GridModel
  from grid_agent import GridAgent
  from parl.algorithms import SAC
  from env_wrapper import get_env
label_desc: Use image node_id 2 for calling the Learner obj's underlying member method code with example usage: obj.run_sampling() without return types