class_docstr: The base class for Contextual Bandit models. A minimal implementation of a specific model requires providing a specific
      implementation for only the cb_training_step() method.
  The main functionality implemented in this base class is the integration of Offline Evaluation into the training loop.
class_docstr_tok: ["The","base","class","for","Contextual","Bandit","models",".","A","minimal","implementation","of","a","specific","model","requires","providing","a","specific","implementation","for","only","the","cb_training_step","(",")","method",".","The","main","functionality","implemented","in","this","base","class","is","the","integration","of","Offline","Evaluation","into","the","training","loop","."]
code: def _update_recmetrics(
      self, batch: CBInput, batch_idx: int, x: torch.Tensor
  ) -> None:
      recmetric_module = self.recmetric_module
      if (recmetric_module is not None) and (
          batch_idx % self.log_every_n_steps == 0
      ):
          # get point predictions (expected value, uncertainty is ignored)
          # this could be expensive because the coefficients have to be computed via matrix inversion
          model_output = self.scorer(x)
          preds = model_output["pred_label"]
  
          weight = batch.weight
          if weight is None:
              assert batch.label is not None
              weight = torch.ones_like(batch.label)
          recmetric_module.update(
              {
                  "prediction": preds,
                  "label": batch.label,
                  "weight": weight,
              }
          )
          self._log_recmetrics(step=self.global_step)
  
imports: import logging
  from abc import ABC, abstractmethod
  from typing import final, Optional
  import torch
  from reagent.core.types import CBInput
  from reagent.core.utils import get_rank
  from reagent.evaluation.cb.base_evaluator import BaseOfflineEval
  from reagent.models.cb_base_model import UCBBaseModel
  from reagent.models.mab import MABBaseModel
  from reagent.training.cb.utils import add_chosen_arm_features, get_model_actions
  from reagent.training.reagent_lightning_module import ReAgentLightningModule
  from torchrec.metrics.metric_module import RecMetricModule
label_desc: Use image node_id 8 for calling the BaseCBTrainerWithEval obj's underlying member method code with example usage: obj._update_recmetrics(batch, batch_idx, x) without return types