code: def compute_rewards(weights, dataset, epsilon=0.0):
      """
      Perform inference using epsilon-greedy contextual bandit (without updates).
      """
      context, rewards = dataset
      context = context.type(torch.float32)
  
      # compute scores:
      scores = torch.matmul(weights, context.t()).squeeze()
      explore = (torch.rand(scores.shape[1]) < epsilon).type(
          torch.float32
      )
      rand_scores = torch.rand_like(scores)
      scores.mul_(1 - explore).add_(rand_scores.mul(explore))
  
      # select arm and observe reward:
      selected_arms = scores.argmax(dim=0)
      return rewards[range(rewards.shape[0]), selected_arms]
  
file_path: CrypTen/examples/bandits/membership_inference.py
imports: import argparse
  import logging
  import os
  import pickle
  import examples.util
  import torch
  import visdom
  from examples.multiprocess_launcher import MultiProcessLauncher
label_desc: Use image node_id 1 for calling a global function with example usage: compute_rewards(weights, dataset, epsilon) and returns: rewards