code: def __init__(
      self,
      ticker_list,
      time_interval,
      drl_lib,
      agent,
      cwd,
      net_dim,
      state_dim,
      action_dim,
      API_KEY,
      API_SECRET,
      API_BASE_URL,
      tech_indicator_list,
      turbulence_thresh=30,
      max_stock=1e2,
      latency=None,
  ):
      # load agent
      self.drl_lib = drl_lib
      if agent == "ppo":
          if drl_lib == "elegantrl":
              agent_class = AgentPPO
              agent = agent_class(net_dim, state_dim, action_dim)
              actor = agent.act
              # load agent
              try:
                  cwd = cwd + "/actor.pth"
                  print(f"| load actor from: {cwd}")
                  actor.load_state_dict(
                      torch.load(
                          cwd, map_location=lambda storage, loc: storage
                      )
                  )
                  self.act = actor
                  self.device = agent.device
              except BaseException:
                  raise ValueError("Fail to load agent!")
  
          elif drl_lib == "rllib":
              from ray.rllib.agents import ppo
              from ray.rllib.agents.ppo.ppo import PPOTrainer
  
              config = ppo.DEFAULT_CONFIG.copy()
              config["env"] = StockEnvEmpty
              config["log_level"] = "WARN"
              config["env_config"] = {
                  "state_dim": state_dim,
                  "action_dim": action_dim,
              }
              trainer = PPOTrainer(env=StockEnvEmpty, config=config)
              trainer.restore(cwd)
              try:
                  trainer.restore(cwd)
                  self.agent = trainer
                  print("Restoring from checkpoint path", cwd)
              except:
                  raise ValueError("Fail to load agent!")
  
          elif drl_lib == "stable_baselines3":
              from stable_baselines3 import PPO
  
              try:
                  # load agent
                  self.model = PPO.load(cwd)
                  print("Successfully load model", cwd)
              except:
                  raise ValueError("Fail to load agent!")
  
          else:
              raise ValueError(
                  "The DRL library input is NOT supported yet. Please check your input."
              )
  
      else:
          raise ValueError("Agent input is NOT supported yet.")
  
      # connect to Alpaca trading API
      try:
          self.alpaca = tradeapi.REST(
              API_KEY, API_SECRET, API_BASE_URL, "v2"
          )
      except:
          raise ValueError(
              "Fail to connect Alpaca. Please check account info and internet connection."
          )
  
      # read trading time interval
      if time_interval == "1s":
          self.time_interval = 1
      elif time_interval == "5s":
          self.time_interval = 5
      elif time_interval == "1Min":
          self.time_interval = 60
      elif time_interval == "5Min":
          self.time_interval = 60 * 5
      elif time_interval == "15Min":
          self.time_interval = 60 * 15
      else:
          raise ValueError("Time interval input is NOT supported yet.")
  
      # read trading settings
      self.tech_indicator_list = tech_indicator_list
      self.turbulence_thresh = turbulence_thresh
      self.max_stock = max_stock
  
      # initialize account
      self.stocks = np.asarray([0] * len(ticker_list))  # stocks holding
      self.stocks_cd = np.zeros_like(self.stocks)
      self.cash = None  # cash record
      self.stocks_df = pd.DataFrame(
          self.stocks, columns=["stocks"], index=ticker_list
      )
      self.asset_list = []
      self.price = np.asarray([0] * len(ticker_list))
      self.stockUniverse = ticker_list
      self.turbulence_bool = 0
      self.equities = []
  
imports: from __future__ import annotations
  import datetime
  import threading
  import time
  import alpaca_trade_api
  import gym
  import numpy
  import pandas
  import torch
  from finrl.meta.data_processors.processor_alpaca import AlpacaProcessor
  from finrl.meta.paper_trading.common import AgentPPO
label_desc: Use image node_id 1 to create a new PaperTradingAlpaca object  with example: obj = PaperTradingAlpaca(ticker_list, time_interval, drl_lib, agent, cwd, net_dim, state_dim, action_dim, API_KEY, API_SECRET, API_BASE_URL, tech_indicator_list, turbulence_thresh, max_stock, latency)