defload_data(root_dir:Optional[str]=None,seq_length:int=100)->Tuple[NumpyDataset,List[str]]:"""Load and return the Shakespeare dataset. Shakespeare dataset is a collection of texts written by Shakespeare. Sourced from https://storage.googleapis.com/download.tensorflow.org/data/shakespeare.txt Args: root_dir: The path to store the downloaded data. When `path` is not provided, the data will be saved into `fastestimator_data` under the user's home directory. seq_length: Length of data sequence. Returns: (train_data, vocab) """home=str(Path.home())ifroot_dirisNone:root_dir=os.path.join(home,'fastestimator_data','Shakespeare')else:root_dir=os.path.join(os.path.abspath(root_dir),'Shakespeare')os.makedirs(root_dir,exist_ok=True)file_path=os.path.join(root_dir,'shakespeare.txt')download_link='https://storage.googleapis.com/download.tensorflow.org/data/shakespeare.txt'ifnotos.path.exists(file_path):# Downloadprint("Downloading data: {}".format(file_path))wget.download(download_link,file_path,bar=bar_custom)withopen(file_path,'rb')asf:text_data=f.read().decode(encoding='utf-8')# Build dictionary from training datavocab=sorted(set(text_data))# Creating a mapping from unique characters to indiceschar2idx={u:ifori,uinenumerate(vocab)}text_data=[char2idx[c]forcintext_data]+[0]*(seq_length-len(text_data)%seq_length)text_data=np.array(text_data).reshape(-1,seq_length)train_data=NumpyDataset(data={"x":text_data})returntrain_data,vocab