<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def clean(self, global_epoch_idx):
 """ Clean old checkpoints """

        if self.cleaned:
            return

        self.cleaned = True
        self.backend.clean(global_epoch_idx)

        self._make_sure_dir_exists()

        for x in os.listdir(self.model_config.checkpoint_dir()):
            match = re.match('checkpoint_(\\d+)\\.data', x)

            if match:
                idx = int(match[1])

                if idx > global_epoch_idx:
                    os.remove(os.path.join(self.model_config.checkpoint_dir(), x))

            match = re.match('checkpoint_hidden_(\\d+)\\.data', x)

            if match:
                idx = int(match[1])

                if idx > global_epoch_idx:
                    os.remove(os.path.join(self.model_config.checkpoint_dir(), x))

            match = re.match('checkpoint_best_(\\d+)\\.data', x)

            if match:
                idx = int(match[1])

                if idx > global_epoch_idx:
                    os.remove(os.path.join(self.model_config.checkpoint_dir(), x))