code: def epsilon_greedy(
      sampler,
      epsilon=0.0,
      backend="mpc",
      nr_iters=7,
      precision=20,
      monitor_func=None,
      checkpoint_func=None,
      checkpoint_every=0,
  ):
      """
      Run epsilon-greedy linear least squares 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.
      """
  
      set_precision(precision)
  
      # define scoring function
      def score_func(scores, A_inv, b, context):
          explore = crypten.bernoulli(torch.tensor([epsilon]))
          rand_scores = crypten.rand(*scores.size())
          scores.mul_(1 - explore).add_(rand_scores.mul(explore))
  
      # run online learner:
      online_learner(
          sampler,
          backend=backend,
          score_func=score_func,
          monitor_func=monitor_func,
          checkpoint_func=checkpoint_func,
          checkpoint_every=checkpoint_every,
          nr_iters=nr_iters,
      )
  
file_path: CrypTen/examples/bandits/private_contextual_bandits.py
imports: import random
  import time
  import crypten
  import torch
  from crypten.config import cfg
label_desc: Use image node_id 3 for calling a global function with example usage: epsilon_greedy(sampler, epsilon, backend, nr_iters, precision, monitor_func, checkpoint_func, checkpoint_every) without return types