code: def test_append_and_sample(self):
      rbuf = replay_buffers.PrioritizedEpisodicReplayBuffer(
          capacity=self.capacity,
          normalize_by_max=self.normalize_by_max,
          default_priority_func=self.default_priority_func,
          uniform_ratio=self.uniform_ratio,
          wait_priority_after_sampling=self.wait_priority_after_sampling,
          return_sample_weights=self.return_sample_weights,
      )
  
      for n in [10, 15, 5] * 3:
          transs = [
              dict(
                  state=i,
                  action=100 + i,
                  reward=200 + i,
                  next_state=i + 1,
                  next_action=101 + i,
                  is_state_terminal=(i == n - 1),
              )
              for i in range(n)
          ]
          for trans in transs:
              rbuf.append(**trans)
  
      assert len(rbuf) == 90
      assert rbuf.n_episodes == 9
  
      for k in [10, 30, 90]:
          s = rbuf.sample(k)
          assert len(s) == k
  
      for k in [1, 3, 9]:
          ret = rbuf.sample_episodes(k)
          if self.return_sample_weights:
              s, wt = ret
              assert len(s) == k
              assert len(wt) == k
          else:
              s = ret
              assert len(s) == k
          if self.wait_priority_after_sampling:
              rbuf.update_errors([1.0] * k)
  
          ret = rbuf.sample_episodes(k, max_len=10)
          if self.return_sample_weights:
              s, wt = ret
              assert len(s) == k
              assert len(wt) == k
          else:
              s = ret
          if self.wait_priority_after_sampling:
              rbuf.update_errors([1.0] * k)
  
          for ep in s:
              assert len(ep) <= 10
              for t0, t1 in zip(ep, ep[1:]):
                  assert t0["next_state"] == t1["state"]
                  assert t0["next_action"] == t1["action"]
  
imports: import collections
  import copy
  import os
  import tempfile
  import unittest
  import numpy
  import pytest
  import torch
  from pfrl import replay_buffer, replay_buffers
label_desc: Use image node_id 2 for calling the TestPrioritizedEpisodicReplayBuffer obj's underlying member method code with example usage: obj.test_append_and_sample() without return types