code: def _encode_pandas_and_key(kv):
      """Converts a (key, RecordBatch) tuple to a list of (key, pd.DataFrame)."""
      k, v = kv
      result = []
      for record_batch in v:
          # to_pandas() returns a DF that may (or always?) contain lists of
          # RecordBatch array contents per-cell. When converting from a CSV there
          # should be exactly one item; this function best-effort unwraps the
          # collection in that case.
          df = record_batch.to_pandas().applymap(_try_unwrap)
          result.append((k, df))
      return result
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import os
  import tempfile
  from typing import List, Mapping, Optional, Text, Tuple, Union
  import apache_beam
  from apache_beam.options.pipeline_options import PipelineOptions
  import pandas
  import pyarrow
  import tensorflow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.api import stats_api
  from tensorflow_data_validation.api import validation_api
  from tensorflow_data_validation.coders import csv_decoder
  from tensorflow_data_validation.statistics import stats_impl
  from tensorflow_data_validation.statistics import stats_options
  from tensorflow_data_validation.utils import io_util
  from tensorflow_data_validation.utils import stats_gen_lib
  from tensorflow_data_validation.utils import stats_util
  from tfx_bsl.coders import example_coder
  from tfx_bsl.tfxio import tf_example_record
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 5 for calling a global function with example usage: _encode_pandas_and_key(kv) and returns: result