code: def ref_batch_matmul(a, b, ta, tb):
      batch_dims_a = a.shape[:-2]
      batch_dims_b = b.shape[:-2]
      if batch_dims_a != batch_dims_b:
          batch_dims = tuple(
              [
                  max(da, db)
                  for da, db in zip(batch_dims_a, batch_dims_b)
              ]
          )
          a = np.broadcast_to(a, batch_dims + a.shape[-2:])
          b = np.broadcast_to(b, batch_dims + b.shape[-2:])
      a = (
          np.transpose(
              a,
              [i for i in range(a.ndim - 2)] + [a.ndim - 1, a.ndim - 2],
          )
          if ta
          else a
      )
      b = (
          np.transpose(
              b,
              [i for i in range(b.ndim - 2)] + [b.ndim - 1, b.ndim - 2],
          )
          if tb
          else b
      )
      y = np.matmul(a, b)
      return y
  
imports: import pytest
  import numpy
  import nnabla.functions
  from nbla_test_utils import list_context
label_desc: Use image node_id 1 for calling a global function with example usage: ref_batch_matmul(a, b, ta, tb) and returns: y