class_docstr: Inverse Propensity Scoring (IPS) estimator
code: def evaluate(
      self, input: BanditsEstimatorInput, **kwargs
  ) -> Optional[EstimatorResult]:
      logger.info("OPE IPS Evaluating")
      log_avg = RunningAverage()
      logged_vals = []
      tgt_avg = RunningAverage()
      tgt_vals = []
      acc_weight = RunningAverage()
      gt_avg = RunningAverage()
      for sample in input.samples:
          log_avg.add(sample.log_reward)
          logged_vals.append(sample.log_reward)
          weight = 0.0
          tgt_result = 0.0
          if sample.log_action.value is not None:
              weight = (
                  0.0
                  if sample.log_action_probabilities[sample.log_action]
                  < PROPENSITY_THRESHOLD
                  else sample.tgt_action_probabilities[
                      sample.log_action
                  ]
                  / sample.log_action_probabilities[sample.log_action]
              )
              weight = self._weight_clamper(weight)
              tgt_result = sample.log_reward * weight
          tgt_avg.add(tgt_result)
          tgt_vals.append(tgt_result)
          acc_weight.add(weight)
          gt_avg.add(sample.ground_truth_reward)
      (
          tgt_score_normalized,
          tgt_std_err,
          tgt_std_err_normalized,
      ) = self._compute_metric_data(
          torch.tensor(tgt_vals), log_avg.average
      )
      return EstimatorResult(
          log_reward=log_avg.average,
          estimated_reward=tgt_avg.average
          if not self._weighted
          else tgt_avg.average / acc_weight.total,
          ground_truth_reward=gt_avg.average,
          estimated_weight=tgt_avg.count,
          estimated_reward_normalized=tgt_score_normalized,
          estimated_reward_std_error=tgt_std_err,
          estimated_reward_normalized_std_error=tgt_std_err_normalized,
      )
  
imports: import logging
  import time
  from abc import ABC, abstractmethod
  from dataclasses import dataclass
  from typing import Optional, Sequence, Tuple, Union
  import numpy
  import torch
  from reagent.ope.estimators.estimator import Estimator, EstimatorResult
  from reagent.ope.estimators.types import Action, ActionDistribution, ActionSpace, Reward, Trainer, TrainingData, Values
  from reagent.ope.utils import Clamper, RunningAverage
  from torch import Tensor
label_desc: Use image node_id 2 for calling the IPSEstimator obj's underlying member method code with example usage: obj.evaluate(input) and returns: EstimatorResult