docstr: Evicts experiences that have been sampled > evict_sampled_more_then times.
docstr_tok: ["Evicts","experiences","that","have","been","sampled",">","evict_sampled_more_then","times","."]
code: def sample(
      self, num_items: int, evict_sampled_more_then: int = 30, **kwargs
  ) -> Optional[SampleBatchType]:
      """Evicts experiences that have been sampled > evict_sampled_more_then times."""
      idxes = [
          random.randint(0, len(self) - 1) for _ in range(num_items)
      ]
      often_sampled_idxes = list(
          filter(
              lambda x: self._hit_count[x] >= evict_sampled_more_then,
              set(idxes),
          )
      )
  
      sample = self._encode_sample(idxes)
      self._num_timesteps_sampled += sample.count
  
      for idx in often_sampled_idxes:
          del self._storage[idx]
          self._hit_count = np.append(
              self._hit_count[:idx], self._hit_count[idx + 1 :]
          )
  
      return sample
  
file_path: ray/rllib/examples/documentation/replay_buffer_demo.py
imports: from typing import Optional
  import random
  import numpy
  from ray import air, tune
  from ray.rllib.utils.replay_buffers import ReplayBuffer, StorageUnit
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.typing import SampleBatchType
  from ray.rllib.utils.replay_buffers.utils import validate_buffer_config
  from ray.rllib.examples.env.random_env import RandomEnv
  from ray.rllib.policy.sample_batch import SampleBatch, concat_samples
  from ray.rllib.algorithms.dqn.dqn import DQNConfig
label_desc: Use image node_id 1 for calling the LessSampledReplayBuffer obj's underlying member method code with example usage: obj.sample(num_items, evict_sampled_more_then) and returns: sample