class_docstr: Hard sampler.
code: def learn_one(self, x, y, **kwargs):
      loss = self.loss(y_true=y, y_pred=self._model_pred_func(x))
  
      if len(self.buffer) < self.size:
          self.buffer.append(Triplet(x=x, y=y, loss=loss))
  
      elif loss > self.buffer[0].loss:
          self.buffer.pop(0)
  
          self.buffer.append(Triplet(x=x, y=y, loss=loss))
  
      # Probability p
      if self._rng.uniform(0, 1) <= self.p:
          i = self._rng.randint(0, len(self.buffer) - 1)
  
          triplet = self.buffer.pop(i)
  
          self.model.learn_one(triplet.x, triplet.y, **kwargs)
  
          loss = self.loss(
              y_true=triplet.y, y_pred=self._model_pred_func(triplet.x)
          )
  
          self.buffer.append(
              Triplet(x=triplet.x, y=triplet.y, loss=loss)
          )
  
      # Probability (1 - p)
      else:
          self.model.learn_one(x, y)
  
imports: from __future__ import annotations
  import collections
  import random
  import typing
  from river import base, linear_model, optim, utils
label_desc: Use image node_id 5 for calling the HardSampling obj's underlying member method code with example usage: obj.learn_one(x, y) without return types