docstr: Tests initialization of `SingleAgentEpisode`.
  
  Three cases are tested:
      1. Empty episode with default starting timestep.
      2. Empty episode starting at `t_started=10`. This is only interesting
          for ongoing episodes, where we do not want to carry on the stale
          entries from the last rollout.
      3. Initialization with pre-collected data.
docstr_tok: ["Tests","initialization","of","`","SingleAgentEpisode","`",".","Three","cases","are","tested",":","1",".","Empty","episode","with","default","starting","timestep",".","2",".","Empty","episode","starting","at","`","t_started=10","`",".","This","is","only","interesting","for","ongoing","episodes",",","where","we","do","not","want","to","carry","on","the","stale","entries","from","the","last","rollout",".","3",".","Initialization","with","pre-collected","data","."]
code: def test_init(self):
      """Tests initialization of `SingleAgentEpisode`.
  
      Three cases are tested:
          1. Empty episode with default starting timestep.
          2. Empty episode starting at `t_started=10`. This is only interesting
              for ongoing episodes, where we do not want to carry on the stale
              entries from the last rollout.
          3. Initialization with pre-collected data.
      """
      # Create empty episode.
      episode = SingleAgentEpisode()
      # Empty episode should have a start point and count of zero.
      self.assertTrue(episode.t_started == episode.t == 0)
  
      # Create an episode with a specific starting point.
      episode = SingleAgentEpisode(t_started=10)
      self.assertTrue(episode.t == episode.t_started == 10)
  
      episode = self._create_episode(num_data=100)
      # The starting point and count should now be at `len(observations) - 1`.
      self.assertTrue(len(episode) == 100)
      self.assertTrue(episode.t == 100)
      self.assertTrue(episode.t_started == 0)
  
      # Build the same episode, but with a 10 ts lookback buffer.
      episode = self._create_episode(
          num_data=100, len_lookback_buffer=10
      )
      # The lookback buffer now takes 10 ts and the length of the episode is only 90.
      self.assertTrue(len(episode) == 90)
      # `t_started` is 0 by default.
      self.assertTrue(episode.t_started == 0)
      self.assertTrue(episode.t == 90)
      self.assertTrue(len(episode.rewards) == 90)
      self.assertTrue(len(episode.rewards.data) == 100)
  
      # Build the same episode, but with a 10 ts lookback buffer AND a specific
      # `t_started`.
      episode = self._create_episode(
          num_data=100, len_lookback_buffer=10, t_started=50
      )
      # The lookback buffer now takes 10 ts and the length of the episode is only 90.
      self.assertTrue(len(episode) == 90)
      self.assertTrue(episode.t_started == 50)
      self.assertTrue(episode.t == 140)
      self.assertTrue(len(episode.rewards) == 90)
      self.assertTrue(len(episode.rewards.data) == 100)
  
imports: from collections import defaultdict
  from typing import Any, Dict, Optional, SupportsFloat, Tuple
  import unittest
  import gymnasium
  from gymnasium.core import ActType, ObsType
  import numpy
  from ray.rllib.env.single_agent_episode import SingleAgentEpisode
  from ray.rllib.utils.test_utils import check
label_desc: Use image node_id 1 for calling the TestSingelAgentEpisode obj's underlying member method code with example usage: obj.test_init() without return types