code: def find_root_and_sink_variables(self):
          '''
          Find root variables of the whole graph
          '''
          # First we assume all variables are roots
          is_root = {name: True for scope in self.scopes for name in scope.variables.keys()}
          # Then, we remove those variables which are outputs of some operators
          for operator in self.unordered_operator_iterator():
              for variable in operator.outputs:
                  is_root[variable.onnx_name] = False
          is_sink = {name: True for scope in self.scopes for name in scope.variables.keys()}
          for operator in self.unordered_operator_iterator():
              for variable in operator.inputs:
                  is_sink[variable.onnx_name] = False
          return [variable for scope in self.scopes for name, variable in scope.variables.items()
                  if is_root[name] or is_sink[name]f find_root_and_sink_variables(self):
          '''
          Find root variables of the whole graph
          '''
          # First we assume all variables are roots
          is_root = {name: True for scope in self.scopes for name in scope.variables.keys()}
          # Then, we remove those variables which are outputs of some operators
          for operator in self.unordered_operator_iterator():
              for variable in operator.outputs:
                  is_root[variable.onnx_name] = False
          is_sink = {name: True for scope in self.scopes for name in scope.variables.keys()}
          for operator in self.unordered_operator_iterator():
              for variable in operator.inputs:
                  is_sink[variable.onnx_name] = False
          return [variable for scope in self.scopes for name, variable in scope.variables.items()
                  if is_root[name] or is_sink[name]]
docs: Find root variables of the whole graph