code: def sample(self, weights, random_action):
      self.agent.set_weights(weights)
  
      obs = self.env.reset()
  
      done = False
      episode_reward, episode_steps = 0, 0
      sample_data = []
      while not done:
          # Select action randomly or according to policy
          if random_action:
              action = np.random.uniform(-1, 1, size=self.action_dim)
          else:
              action = self.agent.sample(obs)
  
          # Perform action
          next_obs, reward, done, info = self.env.step(action)
          terminal = done and not info["timeout"]
          terminal = float(terminal)
  
          sample_data.append((obs, action, reward, next_obs, terminal))
  
          obs = next_obs
          episode_reward += info["origin_reward"]
          episode_steps += 1
  
      return sample_data, episode_steps, episode_reward
  
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 Actor obj's underlying member method code with example usage: obj.sample(weights, random_action) and returns: sample_data,  episode_steps,  episode_reward