class_docstr: Universal Transformer(https://arxiv.org/pdf/1807.03819.pdf) with ACT(https://arxiv.org/pdf/1603.08983.pdf).
docstr: field: 'enc' or 'dec'
docstr_tok: ["field",":","'enc","'","or","'dec","'"]
code: def halt_and_accum(self, name, end=False):
      "field: 'enc' or 'dec'"
      halt = self.halt_enc if name == "enc" else self.halt_dec
      thres = self.thres
  
      def func(nodes):
          p = halt(nodes.data["x"])
          sum_p = nodes.data["sum_p"] + p
          active = (sum_p < thres) & (1 - end)
          _continue = active.float()
          r = (
              nodes.data["r"] * (1 - _continue)
              + (1 - sum_p) * _continue
          )
          s = (
              nodes.data["s"]
              + ((1 - _continue) * r + _continue * p) * nodes.data["x"]
          )
          return {
              "p": p,
              "sum_p": sum_p,
              "r": r,
              "s": s,
              "active": active,
          }
  
      return func
  
imports: from .attention import *
  from .layers import *
  from .functions import *
  from .embedding import *
  import dgl.function
  import torch
  import torch.nn.init
label_desc: Use image node_id 4 for calling the UTransformer obj's underlying member method code with example usage: obj.halt_and_accum(name, end) and returns: func, dict