code: def test_rewrite(inputs, expected):
      inputs = [
          Blockwise(
              *inp,
              numblocks={
                  k: (1,) * len(v) for k, v in inp[-1] if v is not None
              },
          )
          for inp in inputs
      ]
      result = rewrite_blockwise(inputs)
      result2 = (
          result.output,
          "".join(result.output_indices),
          result.dsk,
          [
              (name, "".join(ind) if ind is not None else ind)
              for name, ind in result.indices
          ],
      )
      assert result2 == expected
  
imports: from __future__ import annotations
  import collections
  from operator import add
  import numpy
  import pytest
  import dask
  import dask.array
  from dask.array.utils import assert_eq
  from dask.blockwise import _BLOCKWISE_DEFAULT_PREFIX, Blockwise, _unique_dep, index_subs, optimize_blockwise, rewrite_blockwise
  from dask.highlevelgraph import HighLevelGraph
  from dask.utils_test import dec, hlg_layer_topological, inc
label_desc: Use image node_id 1 for calling a global function with example usage: test_rewrite(inputs, expected) without return types