class_docstr: Custom callback for plotting additional values in tensorboard.
class_docstr_tok: ["Custom","callback","for","plotting","additional","values","in","tensorboard","."]
code: def _on_step(self) -> bool:
      try:
          self.logger.record(
              key="train/reward", value=self.locals["rewards"][0]
          )
  
      except BaseException as error:
          try:
              self.logger.record(
                  key="train/reward", value=self.locals["reward"][0]
              )
  
          except BaseException as inner_error:
              # Handle the case where neither "rewards" nor "reward" is found
              self.logger.record(key="train/reward", value=None)
              # Print the original error and the inner error for debugging
              print("Original Error:", error)
              print("Inner Error:", inner_error)
      return True
  
imports: from __future__ import annotations
  import time
  import numpy
  import pandas
  from stable_baselines3 import A2C
  from stable_baselines3 import DDPG
  from stable_baselines3 import PPO
  from stable_baselines3 import SAC
  from stable_baselines3 import TD3
  from stable_baselines3.common.callbacks import BaseCallback
  from stable_baselines3.common.noise import NormalActionNoise
  from stable_baselines3.common.noise import OrnsteinUhlenbeckActionNoise
  from stable_baselines3.common.vec_env import DummyVecEnv
  from finrl import config
  from finrl.meta.env_stock_trading.env_stocktrading import StockTradingEnv
  from finrl.meta.preprocessor.preprocessors import data_split
label_desc: Use image node_id 2 for calling the TensorboardCallback obj's underlying member method code with example usage: obj._on_step() and returns: True