code: def testComplexPipeline(self):
      # Setup a complex input pipeline.
      batch_size = 2
      num_epochs = 5
      dataset = dataset_ops.Dataset.from_tensor_slices(
          self._createTFRecordFiles()
      )
      dataset = dataset.shuffle(buffer_size=self._num_files)
      dataset = dataset.flat_map(readers.TFRecordDataset)
      dataset = dataset.prefetch(buffer_size=batch_size)
      dataset = dataset.shuffle(2 * self._num_files * self._num_records)
      dataset = dataset.repeat(num_epochs)
      dataset = dataset.map(lambda x: x)
      dataset = dataset.batch(batch_size)
      dataset = dataset.prefetch(buffer_size=None)
  
      # Auto shard.
      dataset = input_ops.auto_shard_dataset(
          dataset, self._num_shards, self._shard_index
      )
  
      # Verify output.
      next_element_fn = self._getNext(dataset)
      actual = []
      num_iterations = (
          self._num_files * self._num_records * num_epochs
      ) // (self._num_shards * batch_size)
      for _ in range(num_iterations):
          actual.extend(self.evaluate(next_element_fn()))
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(next_element_fn())
  
      expected = []
      for f in range(0, self._num_files, self._num_shards):
          for r in range(self._num_records):
              expected.append(self._record(r, f))
      expected *= num_epochs
  
      self.assertAllEqual(sorted(expected), sorted(actual))
  
imports: import os
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import readers
  from tensorflow.python.data.util import structure
  from tensorflow.python.distribute import input_ops
  from tensorflow.python.eager import context
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import test_util
  from tensorflow.python.lib.io import python_io
  from tensorflow.python.ops import gen_dataset_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import test
  from tensorflow.python.util import compat
label_desc: Use image node_id 14 for calling the AutoShardDatasetTest obj's underlying member method code with example usage: obj.testComplexPipeline() without return types