code: def tfrecords_to_dataset_tf2(
      tfrecords_pattern,
      mapping_func,
      batch_size,
      buffer_size=5000,
      shuffle=True,
  ):
      """Generates a TF Dataset from a rio pattern."""
      with tf.name_scope("Input/"):
          tfrecords_pattern = expand_rio_pattern(tfrecords_pattern)
          dataset = tf.data.Dataset.list_files(
              tfrecords_pattern, shuffle=shuffle
          )
          dataset = dataset.interleave(
              tf.data.TFRecordDataset, cycle_length=16
          )
          if shuffle:
              dataset = dataset.shuffle(buffer_size=buffer_size)
          dataset = dataset.map(mapping_func)
          dataset = dataset.batch(batch_size)
          return dataset
  
imports: import re
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: tfrecords_to_dataset_tf2(tfrecords_pattern, mapping_func, batch_size, buffer_size, shuffle) and returns: dataset