class_docstr: Writer class to create kaldi like data directory.
  
  Examples:
      >>> with DatadirWriter("output") as writer:
      ...     # output/sub.txt is created here
      ...     subwriter = writer["sub.txt"]
      ...     # Write "uttidA some/where/a.wav"
      ...     subwriter["uttidA"] = "some/where/a.wav"
      ...     subwriter["uttidB"] = "some/where/b.wav"
class_docstr_tok: ["Writer","class","to","create","kaldi","like","data","directory",".","Examples",":",">",">",">","with","DatadirWriter","(","``","output","''",")","as","writer",":","...","#","output\/sub.txt","is","created","here","...","subwriter","=","writer","[","``","sub.txt","''","]","...","#","Write","``","uttidA","some\/where\/a.wav","''","...","subwriter","[","``","uttidA","''","]","=","``","some\/where\/a.wav","''","...","subwriter","[","``","uttidB","''","]","=","``","some\/where\/b.wav","''"]
code: def __setitem__(self, key: str, value: str):
      assert check_argument_types()
      if self.has_children:
          raise RuntimeError("This writer points out a directory")
      if key in self.keys:
          warnings.warn(f"Duplicated: {key}")
  
      if self.fd is None:
          self.path.parent.mkdir(parents=True, exist_ok=True)
          self.fd = self.path.open("w", encoding="utf-8")
  
      self.keys.add(key)
      self.fd.write(f"{key} {value}\n")
  
file_path: espnet/espnet2/fileio/datadir_writer.py
imports: import warnings
  from pathlib import Path
  from typing import Union
  from typeguard import check_argument_types, check_return_type
label_desc: Use image node_id 4 for calling the DatadirWriter obj's underlying member method code with example usage: obj.__setitem__(key, value) without return types