# Copyright (c) Facebook, Inc. and its affiliates.## This source code is licensed under the MIT license found in the# LICENSE file in the root directory of this source tree.from.importBaseWrapperDatasetclassStripTokenDataset(BaseWrapperDataset):def__init__(self,dataset,id_to_strip):super().__init__(dataset)self.id_to_strip=id_to_stripdef__getitem__(self,index):item=self.dataset[index]whilelen(item)>0anditem[-1]==self.id_to_strip:item=item[:-1]whilelen(item)>0anditem[0]==self.id_to_strip:item=item[1:]returnitem