docs: def write(self, obj: BioCDocument or BioCPassage or BioCSentence):
          """
          Encode and write a single object.
  
          Args:
              obj: an instance of BioCDocument, BioCPassage, or BioCSentence
  
          Returns:
  
          """
          if self.level == DOCUMENT and not isinstance(obj, BioCDocument):
              raise ValueError
          if self.level == PASSAGE and not isinstance(obj, BioCPassage):
              raise ValueError
          if self.level == SENTENCE and not isinstance(obj, BioCSentence):
              raise ValueError
          self.writer.write(BioCJSONEncoder().default(obj))