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","}"]
docstr: Forward can return the mean or a UCB. If returning UCB, the CI width is stddev*ucb_alpha
  If ucb_alpha is not passed in, a fixed alpha from init is used
docstr_tok: ["Forward","can","return","the","mean","or","a","UCB",".","If","returning","UCB",",","the","CI","width","is","stddev","*","ucb_alpha","If","ucb_alpha","is","not","passed","in",",","a","fixed","alpha","from","init","is","used"]
code: def forward(
      self, inp: torch.Tensor, ucb_alpha: Optional[float] = None
  ) -> Dict[str, torch.Tensor]:
      """
      Forward can return the mean or a UCB. If returning UCB, the CI width is stddev*ucb_alpha
      If ucb_alpha is not passed in, a fixed alpha from init is used
      """
      self.calculate_coefs_if_necessary()
      return self._forward_no_coefs_check(inp, ucb_alpha)
  
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 6 for calling the LinearRegressionUCB obj's underlying member method code with example usage: obj.forward(inp, ucb_alpha) and returns: self