code: def test_linucb_training_batch_vs_online(self):
      # make sure that feeding in a batch gives same result as feeding in examples one-by-one
      obss = [[], []]
      for i in range(self.batch_size):
          obss[i].append(
              CBInput(
                  context_arm_features=self.batch[
                      0
                  ].context_arm_features[i : i + 1, :],
                  reward=self.batch[0].reward[[i]],
              )
          )
          obss[i].append(
              CBInput(
                  context_arm_features=self.batch[
                      1
                  ].context_arm_features[i : i + 1, :],
                  reward=self.batch[1].reward[[i]],
              )
          )
  
      scorer_1 = DisjointLinearRegressionUCB(self.num_arms, self.x_dim)
      scorer_2 = DisjointLinearRegressionUCB(self.num_arms, self.x_dim)
      policy_1 = Policy(scorer=scorer_1, sampler=GreedyActionSampler())
      policy_2 = Policy(scorer=scorer_2, sampler=GreedyActionSampler())
      trainer_1 = DisjointLinUCBTrainer(policy_1)
      trainer_2 = DisjointLinUCBTrainer(policy_2)
  
      trainer_1.training_step(obss[0], 0)
      trainer_1.training_step(obss[1], 1)
      trainer_1.on_train_epoch_end()
      trainer_2.training_step(self.batch, 0)
      trainer_2.on_train_epoch_end()
  
      for arm in range(self.num_arms):
          npt.assert_array_less(
              np.zeros(scorer_1.A[arm].shape), scorer_1.A[arm].numpy()
          )  # make sure A got updated
          npt.assert_allclose(
              scorer_1.A[arm].numpy(),
              scorer_2.A[arm].numpy(),
              rtol=1e-4,
          )
          npt.assert_allclose(
              scorer_1.inv_A[arm].numpy(),
              scorer_2.inv_A[arm].numpy(),
              rtol=1e-4,
          )
          npt.assert_allclose(
              scorer_1.b[arm].numpy(),
              scorer_2.b[arm].numpy(),
              rtol=1e-4,
          )
  
file_path: ReAgent/reagent/test/training/cb/test_disjoint_linucb.py
imports: import copy
  import unittest
  import numpy
  import numpy.testing
  import torch
  from reagent.core.types import CBInput
  from reagent.gym.policies.policy import Policy
  from reagent.gym.policies.samplers.discrete_sampler import GreedyActionSampler
  from reagent.models.disjoint_linucb_predictor import DisjointLinearRegressionUCB
  from reagent.training.cb.disjoint_linucb_trainer import DisjointLinUCBTrainer
  from reagent.training.parameters import DisjointLinUCBTrainerParameters
label_desc: Use image node_id 3 for calling the TestDisjointLinUCB obj's underlying member method code with example usage: obj.test_linucb_training_batch_vs_online() without return types