code: def _write(
      self,
      to_write,
      salt: str = "",
      dataset_name: str = "foo",
      split: str = "train",
      disable_shuffling=False,
      file_format=file_adapters.DEFAULT_FILE_FORMAT,
      shard_config: Optional[shard_utils.ShardConfig] = None,
  ):
      filetype_suffix = file_adapters.ADAPTER_FOR_FORMAT[
          file_format
      ].FILE_SUFFIX
      filename_template = naming.ShardedFileTemplate(
          dataset_name=dataset_name,
          split=split,
          filetype_suffix=filetype_suffix,
          data_dir=self.tmp_dir,
      )
      shard_config = shard_config or shard_utils.ShardConfig(
          num_shards=self.NUM_SHARDS
      )
      writer = writer_lib.Writer(
          serializer=testing.DummySerializer("dummy specs"),
          filename_template=filename_template,
          hash_salt=salt,
          disable_shuffling=disable_shuffling,
          file_format=file_format,
          shard_config=shard_config,
      )
      for key, record in to_write:
          writer.write(key, record)
      return writer.finalize()
  
imports: import json
  import os
  from typing import Optional
  from unittest import mock
  from etils import epath
  import tensorflow
  from tensorflow_datasets import testing
  from tensorflow_datasets.core import dataset_utils
  from tensorflow_datasets.core import example_parser
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import lazy_imports_lib
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import writer
  from tensorflow_datasets.core.utils import shard_utils
  from tensorflow_datasets.core.writer import _ShardSpec
label_desc: Use image node_id 1 for calling the WriterTest obj's underlying member method code with example usage: obj._write(to_write, salt, dataset_name, split, disable_shuffling, file_format, shard_config) and returns: writer