code: def write_to_file(self, destination_path):
          
          file_format = os.path.splitext(destination_path)[1][1:]
          metadata = self.get_writable_metadata(file_format)
  
          with open(destination_path, 'w', encoding='utf-8') as f:
              f.write(metadata)
  
          return metadata
docs: Writes the metadata json or xml to a file.
  
          :param destination_path: the file path the file format is inferred
          from the destination_path extension.
          :type destination_path: str
          :return: the written metadata
          :rtype: str