code: def test_flatten():
      @make_funsor
      def Flatten21(
          x: Funsor,
          i: Bound,
          j: Bound,
          ij: Fresh[lambda i, j: Bint[i.size * j.size]],
      ) -> Fresh[lambda x: x]:
          m = to_funsor(i, x.inputs.get(i, None)).output.size
          n = to_funsor(j, x.inputs.get(j, None)).output.size
          ij = to_funsor(ij, Bint[m * n])
          ij = x.materialize(ij)
          return x(
              **{
                  i.name: ij // Number(n, n + 1),
                  j.name: ij % Number(n, n + 1),
              }
          )
  
      inputs = OrderedDict()
      inputs["a"] = Bint[3]
      inputs["b"] = Bint[4]
      data = random_tensor(inputs, Real)
      x = Flatten21(data, "a", "b", "ab")
      assert isinstance(x, Tensor)
  
      check_funsor(x, {"ab": Bint[12]}, Real, data.data.reshape(-1))
  
imports: import math
  from collections import OrderedDict
  import pytest
  import funsor.ops
  from funsor.domains import Array, Bint, Real, Reals
  from funsor.factory import Bound, Fresh, Has, Value, make_funsor, to_funsor
  from funsor.interpretations import reflect
  from funsor.interpreter import reinterpret
  from funsor.tensor import Tensor
  from funsor.terms import Cat, Funsor, Lambda, Number, eager
  from funsor.testing import assert_close, check_funsor, random_tensor, requires_backend
label_desc: Use image node_id 3 for calling a global function with example usage: test_flatten() and returns: x