code: def to_file(self, f):
          
          with open_file_like(f, 'w') as fp:
              json.dump(self.to_list(), fp)
docs: Saves the history as a json file. In order to use this feature,
          the history must only contain JSON encodable Python data structures.
          Numpy and PyTorch types should not be in the history.
  
          Parameters
          ----------
          f : file-like object or str