code: def _infer_ep_from_graph_module(
      graph_module: torch.fx.GraphModule,
  ) -> Tuple[str, ...]:
      """Return the all valid devices (i.e., GPU or CPU) among outputs of this torch.fx.GraphModule."""
      flattened_output_args, _ = _pytree.tree_flatten(
          _extract_graph_module_outputs(graph_module)
      )
      # Output arguments with example value (type: torch.Tensor) in the `graph_module`.
      selected_output_args = [
          output_arg.meta["val"]
          for output_arg in flattened_output_args
          # output_arg must have tensor for its device information.
          # Otherwise, skip it.
          if (hasattr(output_arg, "meta") and "val" in output_arg.meta)
      ]
      return _infer_ep_from_device(*selected_output_args)
  
imports: import dataclasses
  import importlib
  import logging
  from typing import Any, Dict, Final, List, Mapping, Optional, Sequence, Set, Tuple, Union
  from typing_extensions import TypeAlias
  import torch
  import torch._C
  import torch._ops
  import torch._prims.executor
  import torch.fx
  from torch._subclasses.fake_tensor import FakeTensor
  from torch.fx._compatibility import compatibility
  from torch.fx.passes.fake_tensor_prop import FakeTensorProp
  from torch.fx.passes.operator_support import OperatorSupport
  from torch.fx.passes.tools_common import CALLABLE_NODE_OPS
  from torch.utils import _pytree
label_desc: Use image node_id 10 for calling a global function with example usage: _infer_ep_from_graph_module(graph_module) and returns: _infer_ep_from_device