code: def _is_valid_dequant_promotion_pattern(dtype=torch.float32):
      def _inner(match):
          assert dtype in [torch.float32, torch.bfloat16]
          dequant_pattern_end_node = match.output_node()
          if dequant_pattern_end_node.target not in [
              aten.mul.Tensor,
              prims.convert_element_type.default,
              aten.reshape.default,
          ]:
              return False
  
          if dequant_pattern_end_node.target is aten.reshape.default:
              mul_node = (
                  dequant_pattern_end_node.args[
                      0
                  ]  # pattern: linear <- reshape <- mul
                  if dtype == torch.float32
                  else dequant_pattern_end_node.args[0].args[
                      0
                  ]  # pattern: linear <- reshape <- to_bf16 <- mul
              )
          else:
              mul_node = (
                  dequant_pattern_end_node  # pattern: linear <- mul
                  if dtype == torch.float32
                  else dequant_pattern_end_node.args[
                      0
                  ]  # pattern: linear <- to_bf16 <- mul
              )
  
          sub_node = mul_node.args[0]
          to_fp32_node = sub_node.args[0]
          if (
              mul_node.target is aten.mul.Tensor
              and sub_node.target is aten.sub.Tensor
              and to_fp32_node.target
              is prims.convert_element_type.default
              and len(list(dequant_pattern_end_node.users)) > 1
          ):
              # If dequant pattern has more than 1 users, then do dequant promoted
              return True
          return False
  
      return _inner
  
imports: import copy
  import functools
  import itertools
  import math
  import operator
  from typing import Any, Tuple
  import torch
  from torch._dynamo.utils import counters
  from torch.fx.experimental.symbolic_shapes import has_free_symbols
  from ..lowering import lowerings, require_channels_last
  from ..pattern_matcher import Arg, CallFunction, filter_nodes, KeywordArg, ListOf, Match
  from ..utils import pad_listlike
  from .freezing_patterns import register_freezing_graph_pattern
  from .post_grad import register_lowering_pattern
label_desc: Use image node_id 25 for calling a global function with example usage: _is_valid_dequant_promotion_pattern(dtype) and returns: _inner, False, False, True