class_docstr: Wrap a value (int or dict with int keys), so that the computation on it can be replayed.
  It builds a binary tree. If ``value`` is not None, it's a leaf node.
  Otherwise, it has left sub-tree and right sub-tree and an operation.
  
  Only support basic arithmetic operations: ``+``, ``-``, ``*``, ``//``.
docstr: Evaluate the value on root node, after replacing every value on leaf node with ``value_fn``.
  If ``value_fn`` is none, no replacement will happen and the raw value will be used.
docstr_tok: ["Evaluate","the","value","on","root","node",",","after","replacing","every","value","on","leaf","node","with","``","value_fn","``",".","If","``","value_fn","``","is","none",",","no","replacement","will","happen","and","the","raw","value","will","be","used","."]
code: def evaluate(
      self, value_fn: _value_fn_type = None
  ) -> int_or_int_dict:
      """Evaluate the value on root node, after replacing every value on leaf node with ``value_fn``.
      If ``value_fn`` is none, no replacement will happen and the raw value will be used.
      """
      if self.value is not None:
          if value_fn is not None:
              return value_fn(self.value)
          return self.value
      else:
          if isinstance(self.lhs, MaybeWeighted):
              eval_lhs = self.lhs.evaluate(value_fn)
          else:
              eval_lhs = cast(int, self.lhs)
          if isinstance(self.rhs, MaybeWeighted):
              eval_rhs = self.rhs.evaluate(value_fn)
          else:
              eval_rhs = cast(int, self.rhs)
          assert self.operation is not None
          return self.operation(eval_lhs, eval_rhs)
  
imports: from __future__ import annotations
  import operator
  from typing import Callable, Iterator, TypeVar, Any, Optional, Tuple, Union, List, Dict, Generic, cast
  import numpy
  import torch
label_desc: Use image node_id 3 for calling the MaybeWeighted obj's underlying member method code with example usage: obj.evaluate(value_fn) and returns: self, self, value_fn