code: def testConvertToRecordBatchPassthroughData(self):
      passthrough_key1 = "__passthrough_with_batch_length__"
      passthrough_key2 = "__passthrough_with_one_value__"
      passthrough_key3 = "__passthrough_with_one_distinct_value_none__"
      passthrough_key4 = (
          "__passthrough_with_one_distinct_value_not_none__"
      )
      batch_dict = {
          "a": np.array([100, 1, 10], np.int64),
          passthrough_key1: pa.array(
              [[1], None, [0]], pa.large_list(pa.int64())
          ),
          passthrough_key2: pa.array(
              [None], pa.large_list(pa.float32())
          ),
          passthrough_key3: pa.array(
              [None, None], pa.large_list(pa.large_binary())
          ),
          passthrough_key4: pa.array(
              [[10], [10]], pa.large_list(pa.int64())
          ),
      }
      schema = schema_utils.schema_from_feature_spec(
          {"a": tf.io.FixedLenFeature([], tf.int64)}
      )
      converter = impl_helper.make_tensor_to_arrow_converter(schema)
      passthrough_keys = {
          passthrough_key1,
          passthrough_key2,
          passthrough_key3,
          passthrough_key4,
      }
      arrow_schema = pa.schema(
          [
              ("a", pa.large_list(pa.int64())),
              (passthrough_key1, batch_dict[passthrough_key1].type),
              (passthrough_key2, batch_dict[passthrough_key2].type),
              (passthrough_key3, batch_dict[passthrough_key3].type),
              (passthrough_key4, batch_dict[passthrough_key4].type),
          ]
      )
      # Note that we only need `input_metadata.arrow_schema`.
      input_metadata = tensor_adapter.TensorAdapterConfig(
          arrow_schema, {}
      )
      converted = list(
          impl._convert_to_record_batch(
              batch_dict, converter, passthrough_keys, input_metadata
          )
      )
      self.assertLen(converted, 1)
      record_batch, unary_features = converted[0]
      expected_record_batch = {
          "a": [[100], [1], [10]],
          passthrough_key1: [[1], None, [0]],
      }
      self.assertDictEqual(
          expected_record_batch, record_batch.to_pydict()
      )
      expected_unary_features = {
          passthrough_key2: [None],
          passthrough_key3: [None],
          passthrough_key4: [[10]],
      }
      unary_features = {
          k: v.to_pylist() for k, v in unary_features.items()
      }
      self.assertDictEqual(expected_unary_features, unary_features)
  
      # Test pass-through data when input and output batch sizes are different and
      # the number of its unique values is >1.
      passthrough_key5 = "__passthrough_with_wrong_batch_size__"
      passthrough_keys.add(passthrough_key5)
      batch_dict[passthrough_key5] = pa.array(
          [[1], [2]], pa.large_list(pa.int64())
      )
      input_metadata.arrow_schema = input_metadata.arrow_schema.append(
          pa.field(passthrough_key5, batch_dict[passthrough_key5].type)
      )
      with self.assertRaisesRegex(
          ValueError,
          "Cannot pass-through data when "
          "input and output batch sizes are different",
      ):
          _ = list(
              impl._convert_to_record_batch(
                  batch_dict,
                  converter,
                  passthrough_keys,
                  input_metadata,
              )
          )
  
file_path: transform/tensorflow_transform/beam/impl_output_record_batches_test.py
imports: import collections
  import numpy
  import pyarrow
  import tensorflow
  from tensorflow_transform import impl_helper
  from tensorflow_transform.beam import impl
  from tensorflow_transform.beam import impl_test
  from tensorflow_transform.beam import tft_unit
  from tensorflow_transform.tf_metadata import schema_utils
  from tfx_bsl.tfxio import tensor_adapter
label_desc: Use image node_id 3 for calling the BeamImplOutputRecordBatchesTest obj's underlying member method code with example usage: obj.testConvertToRecordBatchPassthroughData() without return types