code: def _has_potential_branch_input_mutation(branch, inputs):
      """
      Dispatch-trace the branch with inputs and check if
      producing graph has mutable op on the input. This is
      bit restrictive as the branch must be traceable.
      """
      try:
          gm = make_fx(branch)(*inputs)
      except UnsupportedAliasMutationException:
          # this can happen when nested cond_op is
          # functionalized
          return True
      except Exception as e:
          raise e
  
      def _detect_input_mutation(gm):
          input_nodes = set()
          for node in gm.graph.nodes:
              if node.op == "placeholder":
                  input_nodes.add(node)
              if node.op == "call_function":
                  target = node.target
                  if (
                      isinstance(target, torch._ops.OpOverload)
                      and target._schema.is_mutable
                  ):
                      for arg in node.args:
                          if arg in input_nodes:
                              return True
  
          for _, module in gm.named_children():
              if isinstance(module, torch.fx.GraphModule):
                  if _detect_input_mutation(module):
                      return True
  
          return False
  
      return _detect_input_mutation(gm)
  
imports: from contextlib import contextmanager
  from dataclasses import dataclass
  import torch
  import torch._subclasses.functional_tensor
  import torch.fx.traceback
  import torch.utils._pytree
  from torch._C import DispatchKey
  from torch._C._functorch import _add_batch_dim, get_unwrapped, is_batchedtensor, maybe_get_bdim
  from torch._functorch.utils import exposed_in
  from torch._higher_order_ops.utils import autograd_not_implemented
  from torch._ops import HigherOrderOperator
  from torch._subclasses.fake_tensor import FakeTensorMode
  from torch.fx.experimental.proxy_tensor import disable_proxy_modes_tracing, make_fx, ProxyTorchDispatchMode, track_tensor_tree
  from torch.fx.passes.shape_prop import _extract_tensor_metadata
  from torch.multiprocessing.reductions import StorageWeakRef
  from torch.utils._python_dispatch import _get_current_dispatch_mode
label_desc: Use image node_id 8 for calling a global function with example usage: _has_potential_branch_input_mutation(branch, inputs) and returns: _detect_input_mutation, False, True, True, True