class_docstr: Factorization Machines base class.
code: def _learn_one(self, x, y, w=1.0):
      # Calculate the gradient of the loss with respect to the raw output
      g_loss = self.loss.gradient(y_true=y, y_pred=self._raw_dot(x))
  
      # Clamp the gradient to avoid numerical instability
      g_loss = utils.math.clamp(
          g_loss,
          minimum=-self.clip_gradient,
          maximum=self.clip_gradient,
      )
  
      # Apply the sample weight
      g_loss *= w
  
      # Update the intercept
      intercept_lr = self.intercept_lr.get(
          self.weight_optimizer.n_iterations
      )
      self.intercept -= intercept_lr * g_loss
  
      # Update the weights
      weights_gradient = self._calculate_weights_gradients(x, g_loss)
      self.weights = self.weight_optimizer.step(
          w=self.weights, g=weights_gradient
      )
  
      # Update the latent weights
      self._update_latents(x, g_loss)
  
imports: from __future__ import annotations
  import abc
  import collections
  import numbers
  from collections.abc import Iterable
  import numpy
  from river import optim, utils
label_desc: Use image node_id 5 for calling the BaseFM obj's underlying member method code with example usage: obj._learn_one(x, y, w) without return types