code: def GateBranches(x, **unused_kwargs):
    
    assert len(x) == 3, x
    state, gate, candidate = x
    return gate * state + (1.0 - gate) * candidate
docs: Implements a gating function on a (memory, gate, candidate) tuple.
  
    Final update is memory * gate + (1-gate) * candidate
  
    This gating equation may also be referred to as Highway Network.
    Highway Networks: https://arxiv.org/abs/1505.00387
  
    Args:
      x: A tuple of (memory, gate, candidate)
  
    Returns:
      The result of applying gating.