class_docstr: The trainer for Disjoint LinUCB Contextual Bandit model.
  The model estimates a ridge regression (linear) and only supports dense features.
  
  Args:
      policy: The policy to be trained. Its scorer has to be DisjointLinearRegressionUCB
class_docstr_tok: ["The","trainer","for","Disjoint","LinUCB","Contextual","Bandit","model",".","The","model","estimates","a","ridge","regression","(","linear",")","and","only","supports","dense","features",".","Args",":","policy",":","The","policy","to","be","trained",".","Its","scorer","has","to","be","DisjointLinearRegressionUCB"]
docstr: Update A and b for arm with index arm_idx
  Args:
      arm_idx: the index of the arm to be updated
      x: 2D tensor of shape (batch_size, dim)
      y: 2D tensor of shape (batch_size, 1)
      weight: 2D tensor of shape (batch_size, 1)
docstr_tok: ["Update","A","and","b","for","arm","with","index","arm_idx","Args",":","arm_idx",":","the","index","of","the","arm","to","be","updated","x",":","2D","tensor","of","shape","(","batch_size",",","dim",")","y",":","2D","tensor","of","shape","(","batch_size",",","1",")","weight",":","2D","tensor","of","shape","(","batch_size",",","1",")"]
code: def update_params(
      self,
      arm_idx: int,
      x: torch.Tensor,
      y: Optional[torch.Tensor],
      weight: Optional[torch.Tensor] = None,
  ):
      """
      Update A and b for arm with index arm_idx
      Args:
          arm_idx: the index of the arm to be updated
          x: 2D tensor of shape (batch_size, dim)
          y: 2D tensor of shape (batch_size, 1)
          weight: 2D tensor of shape (batch_size, 1)
      """
      # weight is number of observations represented by each entry
      if weight is None:
          weight = torch.ones_like(torch.tensor(y))
      weight = weight.float()
  
      self.scorer.cur_num_obs[arm_idx] += torch.tensor(y).shape[0]
  
      self.scorer.cur_A[arm_idx] += torch.matmul(
          x.t(), x * weight
      )  # dim (DA*DC, DA*DC)
      self.scorer.cur_b[arm_idx] += torch.matmul(
          x.t(), y * weight
      ).squeeze()
  
file_path: ReAgent/reagent/training/cb/disjoint_linucb_trainer.py
imports: import logging
  from typing import List, Optional
  import torch
  from reagent.core.configuration import resolve_defaults
  from reagent.core.types import CBInput
  from reagent.gym.policies.policy import Policy
  from reagent.models.disjoint_linucb_predictor import DisjointLinearRegressionUCB
  from reagent.training.cb.base_trainer import BaseCBTrainerWithEval
label_desc: Use image node_id 3 for calling the DisjointLinUCBTrainer obj's underlying member method code with example usage: obj.update_params(arm_idx, x, y, weight) without return types