code: def benchmark_matmul(
      dims: MatmulSize,
      pbar: tqdm.std.tqdm,
      shared_stream: torch.cuda.Stream,
      tilings: typing.List[MatmulTiling],
      repetitions_ms: int,
      debug=False,
  ) -> typing.Sequence[MatmulTiming]:
      """For a given matmul configuration, benchmark it.
  
      Args:
        dims: the dimensions of the matmul
        pbar: a progress bar
        shared_stream: stream to execute benchmarks on
        tilings: list of tilings to benchmark
        repetitions_ms: how many milliseconds to spend running each configuration
        debug: whether to print debug output
  
      Returns:
        A sequence of matmul timings.
      """
      out: list[MatmulTiming] = []
      largest_splitk = max(tilings, key=lambda t: t.SPLIT_K).SPLIT_K
  
      s = torch.cuda.Stream()
  
      # Use our own stream for compilation.
      with torch.cuda.stream(s):
          a = _init_matmul_argument(dims.M, dims.K, dims.quantized_lhs)
          b = _init_matmul_argument(dims.K, dims.N, dims.quantized_rhs)
          data_a = getattr(a, "base", a)
          data_b = getattr(b, "base", b)
  
          assert (
              data_a.shape[1] == data_b.shape[0]
          ), "incompatible dimensions"
          assert data_a.is_contiguous(), "matrix A must be contiguous"
          assert data_b.is_contiguous(), "matrix B must be contiguous"
          ctype = _get_common_type(a.dtype, b.dtype)
          c = torch.empty(
              (dims.M, dims.N), device=a.device, dtype=ctype
          )
          scratchpad = torch.empty(
              (largest_splitk, dims.M, dims.N),
              device=a.device,
              dtype=ctype,
          )
  
      LOG.info("Autotuning for %s", dims)
  
      for tiling in tilings:
          pbar.update(1)
  
          timing = benchmark_matmul_tiling(
              dims,
              tiling,
              s,
              shared_stream,
              a,
              b,
              c,
              scratchpad,
              repetitions_ms=repetitions_ms,
              debug=debug,
          )
          if not timing:
              continue
  
          out.append(timing)
      return out
  
imports: import enum
  import itertools
  import logging
  import math
  import typing
  import torch
  import tqdm
  import triton
  import triton.language
label_desc: Use image node_id 13 for calling a global function with example usage: benchmark_matmul(dims, pbar, shared_stream, tilings, repetitions_ms, debug) and returns: out