code: def make_arrow_record_batches_equal_fn(
      test: absltest.TestCase,
      expected_record_batches: List[pa.RecordBatch],
  ):
      """Makes a matcher function for comparing arrow record batches."""
  
      def _matcher(actual_record_batches: Iterable[pa.RecordBatch]):
          """Arrow record batches matcher fn."""
          actual_record_batches = list(actual_record_batches)
          test.assertLen(
              actual_record_batches, len(expected_record_batches)
          )
          for i in range(len(expected_record_batches)):
              actual_record_batch = actual_record_batches[i]
              expected_record_batch = expected_record_batches[i]
              test.assertEqual(
                  expected_record_batch.num_columns,
                  actual_record_batch.num_columns,
                  "Expected {} columns, found {} in record_batch {}".format(
                      expected_record_batch.num_columns,
                      actual_record_batch.num_columns,
                      actual_record_batch,
                  ),
              )
              for column_name, expected_column in zip(
                  expected_record_batch.schema.names,
                  expected_record_batch.columns,
              ):
                  field_index = (
                      actual_record_batch.schema.get_field_index(
                          column_name
                      )
                  )
                  test.assertGreaterEqual(
                      field_index,
                      0,
                      "Unable to find column {}".format(column_name),
                  )
                  actual_column = actual_record_batch.column(
                      field_index
                  )
                  test.assertTrue(
                      actual_column.equals(expected_column),
                      "{}: {} vs {}".format(
                          column_name, actual_column, expected_column
                      ),
                  )
  
      return _matcher
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import traceback
  from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union
  from absl.testing import absltest
  import apache_beam
  from apache_beam.testing import util
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.statistics.generators import stats_generator
  from tensorflow.python.util.protobuf import compare
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 8 for calling a global function with example usage: make_arrow_record_batches_equal_fn(test, expected_record_batches) and returns: _matcher