The number of operations which use each tensor as input.

    Returns:
      a {string, int} mapping tensor name to the number of operations which use
      it as input, or one plus that quantity if the tensor is final.

def _compute_initial_out_degree(self):
    """The number of operations which use each tensor as input.

    Returns:
      a {string, int} mapping tensor name to the number of operations which use
      it as input, or one plus that quantity if the tensor is final.
    """
    out_degree = collections.defaultdict(int)

    # Pretend that final tensors have an additional degree so they are not
    # freed.
    for tensor_name in self.get_all_tensor_names():
      if self.is_tensor_final(tensor_name):
        out_degree[tensor_name] = 1

    for operation_name in self.get_all_operation_names():
      for input_name in self.get_operation_input_names(operation_name):
        out_degree[input_name] += 1

    return out_degree