import re


def _expand_tfrecords_pattern(tfr_pattern):
  """Helper function to expand a tfrecord patter."""
  def format_shards(m):
    return '{}-?????-of-{:0>5}{}'.format(*m.groups())
  tfr_pattern = re.sub(r'^([^@]+)@(\d+)([^@]+)$', format_shards, tfr_pattern)
  return tfr_pattern