class_docstr: A linear regression model for LinUCB.
  Note that instead of being trained by a PyTorch optimizer, we explicitly
      update attributes A and b (according to the LinUCB formulas implemented in
      reagent.training.cb.linucb_trainer.LinUCBTrainer).
  Since computing the regression coefficients inverse matrix inversion (expensive op), we
      save time by only computing the coefficients when necessary (when doing inference).
  
  Args:
      input_dim: Dimension of input data
      l2_reg_lambda: The weight on L2 regularization
      ucb_alpha: The coefficient on the standard deviation in UCB formula.
          Set it to 0 to predict the expected value instead of UCB.
      gamma: per-epoch discount factor (A and b get multiplied by gamma every epoch)
  
  Outputs:
  Dict {"pred_label": pred_label, "pred_sigma": pred_sigma, "ucb": ucb}
class_docstr_tok: ["A","linear","regression","model","for","LinUCB",".","Note","that","instead","of","being","trained","by","a","PyTorch","optimizer",",","we","explicitly","update","attributes","A","and","b","(","according","to","the","LinUCB","formulas","implemented","in","reagent.training.cb.linucb_trainer.LinUCBTrainer",")",".","Since","computing","the","regression","coefficients","inverse","matrix","inversion","(","expensive","op",")",",","we","save","time","by","only","computing","the","coefficients","when","necessary","(","when","doing","inference",")",".","Args",":","input_dim",":","Dimension","of","input","data","l2_reg_lambda",":","The","weight","on","L2","regularization","ucb_alpha",":","The","coefficient","on","the","standard","deviation","in","UCB","formula",".","Set","it","to","0","to","predict","the","expected","value","instead","of","UCB",".","gamma",":","per-epoch","discount","factor","(","A","and","b","get","multiplied","by","gamma","every","epoch",")","Outputs",":","Dict","{","``","pred_label","''",":","pred_label",",","``","pred_sigma","''",":","pred_sigma",",","``","ucb","''",":","ucb","}"]
code: def _forward_no_coefs_check(
      self, inp: torch.Tensor, ucb_alpha: Optional[float] = None
  ) -> Dict[str, torch.Tensor]:
      # perform forward pass without checking if the current coefficient estimate is still valid
      if ucb_alpha is None:
          ucb_alpha = self.ucb_alpha
  
      pred_label = torch.matmul(inp, self._coefs)
  
      if ucb_alpha != 0:
          pred_sigma = torch.sqrt(
              batch_quadratic_form(inp, self.inv_avg_A)
              / self.sum_weight
          )
      else:
          pred_sigma = torch.zeros_like(pred_label)
  
      # we should throw when pred_sigma has nan value
      if torch.any(torch.isnan(pred_sigma)):
          raise Exception("pred_sigma has nan values")
  
      ucb = pred_label + ucb_alpha * pred_sigma
      return {
          "pred_label": pred_label,
          "pred_sigma": pred_sigma,
          "ucb": ucb,
      }
  
file_path: ReAgent/reagent/models/linear_regression.py
imports: import logging
  from typing import Dict, Optional
  import torch
  from pytorch_lightning.utilities.distributed import ReduceOp, sync_ddp_if_available
  from reagent.models.cb_base_model import UCBBaseModel
label_desc: Use image node_id 5 for calling the LinearRegressionUCB obj's underlying member method code with example usage: obj._forward_no_coefs_check(inp, ucb_alpha) and returns: dict