code: def write_to_directory(
      self, dataset_infos_dir, overwrite=False, pretty_print=False
  ) -> None:
      total_dataset_infos = {}
      dataset_infos_path = os.path.join(
          dataset_infos_dir, config.DATASETDICT_INFOS_FILENAME
      )
      dataset_readme_path = os.path.join(
          dataset_infos_dir, config.REPOCARD_FILENAME
      )
      if not overwrite:
          total_dataset_infos = self.from_directory(dataset_infos_dir)
      total_dataset_infos.update(self)
      if os.path.exists(dataset_infos_path):
          # for backward compatibility, let's update the JSON file if it exists
          with open(dataset_infos_path, "w", encoding="utf-8") as f:
              dataset_infos_dict = {
                  config_name: asdict(dset_info)
                  for config_name, dset_info in total_dataset_infos.items()
              }
              json.dump(
                  dataset_infos_dict,
                  f,
                  indent=4 if pretty_print else None,
              )
      # Dump the infos in the YAML part of the README.md file
      if os.path.exists(dataset_readme_path):
          dataset_card = DatasetCard.load(dataset_readme_path)
          dataset_card_data = dataset_card.data
      else:
          dataset_card = None
          dataset_card_data = DatasetCardData()
      if total_dataset_infos:
          total_dataset_infos.to_dataset_card_data(dataset_card_data)
          dataset_card = (
              DatasetCard("---\n" + str(dataset_card_data) + "\n---\n")
              if dataset_card is None
              else dataset_card
          )
          dataset_card.save(Path(dataset_readme_path))
  
imports: import copy
  import dataclasses
  import json
  import os
  import posixpath
  import warnings
  from dataclasses import dataclass
  from pathlib import Path
  from typing import ClassVar, Dict, List, Optional, Union
  import fsspec
  from huggingface_hub import DatasetCard, DatasetCardData
  from .None import config
  from .features import Features, Value
  from .splits import SplitDict
  from .tasks import TaskTemplate, task_template_from_dict
  from .utils import Version
  from .utils.logging import get_logger
  from .utils.py_utils import asdict, unique_values
label_desc: Use image node_id 1 for calling the DatasetInfosDict obj's underlying member method code with example usage: obj.write_to_directory(dataset_infos_dir, overwrite, pretty_print) without return types