code: def linucb(
      sampler,
      epsilon=0.1,
      dtype=torch.double,
      device="cpu",
      monitor_func=None,
      checkpoint_func=None,
      checkpoint_every=0,
  ):
      """
      Run LinUCB contextual bandit learner on dataset.
  
      The `sampler` is expected to be an iterator that returns one sample at a time.
      Samples are assumed to be `dict`s with a `'context'` and a `'rewards'` field.
  
      The function takes a hyperpameter `epsilon`, `dtype`, and `device` as optional
      arguments. It also takes an optional `monitor_func` closure that does logging,
      and an optional `checkpoint_func` that does checkpointing.
  
      Implementation following https://arxiv.org/pdf/1003.0146.pdf
      """
  
      # define UCB scoring function:
      def score_func(scores, A_inv, b, context):
          for arm in range(scores.nelement()):
              scores[arm] += (
                  context.matmul(A_inv[arm, :, :])
                  .dot(context)
                  .sqrt_()
                  .mul_(epsilon)
              )
  
      # run online learner:
      online_learner(
          sampler,
          dtype=dtype,
          device=device,
          score_func=score_func,
          monitor_func=monitor_func,
          checkpoint_func=checkpoint_func,
          checkpoint_every=checkpoint_every,
      )
  
imports: import random
  import time
  import torch
label_desc: Use image node_id 3 for calling a global function with example usage: linucb(sampler, epsilon, dtype, device, monitor_func, checkpoint_func, checkpoint_every) without return types