code: def _format_target(self, net, f, idx):
          
          if f is None:
              return None
          if isinstance(f, str):
              f = self.fn_prefix + f.format(
                  net=net,
                  last_epoch=net.history[idx],
                  last_batch=net.history[idx, 'batches', -1],
              )
              return os.path.join(self.dirname, f)
          return f
docs: Apply formatting to the target filename template.