code: def _is_op_stateful(op):
      """Check whether an op is stateful.
  
      This helper function handles two special cases to make the stateful analysis
      consistent with the mlir side effect analysis.
      1. GlobalIterIdOp should be stateless.
      2. CollectiveGatherV2 with attribute is_stateless to be True should be
         stateless.
  
      Args:
       op: Operation
  
      Returns:
        Boolean indicates whether the operation is stateless or not.
      """
      # TODO(pineapplejuice233): Remove these hardcode op names once they can be marked as
      # stateless in TF.
      if op.type == "GlobalIterId":
          return False
      if op.type == "UpdateFdoWithGlobalMinibatchStatistics":
          return False
      if op.type == "CollectiveGatherV2" and op.get_attr(
          "is_stateless"
      ):
          return False
      return op._is_stateful
  
imports: import collections
  from tensorflow.core.framework import types_pb2
  from tensorflow.python.eager import backprop_util
  from tensorflow.python.framework import auto_control_deps
  from tensorflow.python.framework import auto_control_deps_utils
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.framework import func_graph
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import none_tensor
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.framework import type_spec
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.ops import control_flow_util_v2
  from tensorflow.python.ops import default_gradient
  from tensorflow.python.ops import gen_functional_ops
  from tensorflow.python.ops import gen_optional_ops
  from tensorflow.python.ops import gradients_util
  from tensorflow.python.ops import handle_data_util
  from tensorflow.python.ops import math_ops
  from tensorflow.python.util import nest
label_desc: Use image node_id 3 for calling a global function with example usage: _is_op_stateful(op) and returns: op, False, False, False