code: def write(self):
          
          # write the next file for all fields
          for field_name in self.field_names:
              filename = self.generate_tensor_filename(field_name, self._num_tensors-1)
              self._tensors[field_name].save(filename, compressed=True)
  
          # write the current metadata to file
          json.dump(self._metadata, open(self.metadata_filename, 'w'),
                    indent=JSON_INDENT,
                    sort_keys=True)
  
          # update
          self._has_unsaved_data = False
docs: Writes all tensors to the next file number.