code: def _is_valid_dequant_linear_pattern(
      dtype, input_dim_exceeds_two, input_contiguous
  ):
      def _inner(match):
          # Check dequant pattern has only 1 user.
          (
              linear_node,
              _,
          ) = _get_linear_node(
              match, input_dim_exceeds_two, input_contiguous
          )
  
          input_index = (
              1 if linear_node.target is aten.addmm.default else 0
          )
          assert dtype in [torch.float32, torch.bfloat16]
  
          (
              mul_node,
              _,
              _,
              _,
          ) = _get_linear_dq_mul_node(
              linear_node,
              input_index,
              dtype,
              input_dim_exceeds_two,
              input_contiguous,
          )
  
          sub_node = mul_node.args[0]
          to_fp32_node = sub_node.args[0]
  
          assert (
              to_fp32_node.target is prims.convert_element_type.default
          )
          assert sub_node.target is aten.sub.Tensor
          assert mul_node.target is aten.mul.Tensor
          if (
              len(list(to_fp32_node.users)) != 1
              or len(list(sub_node.users)) != 1
              or len(list(mul_node.users)) != 1
          ):
              # Ensure the dequant pattern only has 1 user
              # since we will delete the dequant pattern here
              return False
  
          # Extra check for bmm pattern
          if input_dim_exceeds_two and not input_contiguous:
              # Check for act
              # Act expand size should be exactly same as act size
              act_expand_size = match.kwargs["act_expand_size"]
              act_node = match.kwargs["x"]
              if not (
                  hasattr(act_node, "meta")
                  and isinstance(
                      act_node.meta.get("val", None), torch.Tensor
                  )
                  and (
                      act_node.meta["val"].size()
                      == torch.Size(act_expand_size)
                  )
              ):
                  return False
  
              # Check for wgt
              # wgt permute dims should be [1, 0]
              wgt_permute_dims = match.kwargs["permute_axes"]
              if wgt_permute_dims != [1, 0]:
                  return False
  
              # Check below wgt size items:
              # wgt before expand should with dim 2
              # Expand size should with dim 3
              # Expand size[0] should same as act size[0]
              # Expand size[1] should same as wgt size[0]
              # Expand size[2] should same as wgt size[1]
              qweight_node = match.kwargs["q_weight"]
              wgt_expand_size = match.kwargs["wgt_expand_size"]
              if not (
                  hasattr(qweight_node, "meta")
                  and isinstance(
                      qweight_node.meta.get("val", None), torch.Tensor
                  )
                  and len(qweight_node.meta["val"].size()) == 2
                  and len(wgt_expand_size) == 3
                  and wgt_expand_size[0]
                  == act_node.meta["val"].size()[0]
                  and wgt_expand_size[1]
                  == qweight_node.meta["val"].size()[0]
                  and wgt_expand_size[2]
                  == qweight_node.meta["val"].size()[1]
              ):
                  return False
  
          return True
  
      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 33 for calling a global function with example usage: _is_valid_dequant_linear_pattern(dtype, input_dim_exceeds_two, input_contiguous) and returns: _inner, True, False, False, False, False