code: def _sorted_incoming_edges(node: Node) -> List[Edge]:
      edges = [edge for edge in node.graph.edges if edge.tail is node]
      _logger.debug("sorted_incoming_edges: %s", str(edges))
      if not edges:
          return []
      _logger.debug(
          "all tail_slots are None: %s",
          str([edge.tail_slot for edge in edges]),
      )
      if all(edge.tail_slot is None for edge in edges):
          return edges
      if all(isinstance(edge.tail_slot, int) for edge in edges):
          edges = sorted(
              edges, key=(lambda edge: cast(int, edge.tail_slot))
          )
          if [edge.tail_slot for edge in edges] == list(
              range(len(edges))
          ):
              return edges
      raise IllegalGraphError(
          node.graph, "Node {} has bad inputs".format(node.name)
      )
  
file_path: nni/nni/nas/space/pytorch/codegen.py
imports: import logging
  import re
  from typing import Dict, List, Tuple, Any, cast
  from nni.common.device import Device, GPUDevice
  from nni.nas.space.graph import IllegalGraphError, Edge, Graph, Node, GraphModelSpace
  from nni.nas.space.graph_op import PyTorchOperation
  from nni.nas.utils import STATE_DICT_PY_MAPPING
  from .op_def import ToDevice
label_desc: Use image node_id 2 for calling a global function with example usage: _sorted_incoming_edges(node) and returns: list, edges, edges