code: def _write_tfrecord_from_shard_spec(shard_spec, get):
      """Write tfrecord shard given shard_spec and buckets to read data from.
  
      Args:
        shard_spec: _ShardSpec, the spec for shard to write.
        get: callable taking the shard index (of bucket) and returning iterator over
          its elements.
      """
      iterators = []
      for instruction in shard_spec.file_instructions:
          iterator = get(int(instruction.filename))
          skip, take = instruction.skip, instruction.take
          stop = skip + take if take > 0 else None
          iterators.append(itertools.islice(iterator, skip, stop))
      writer_lib._write_examples(
          shard_spec.path, itertools.chain(*iterators)
      )
  
imports: import functools
  import itertools
  import os
  from unittest import mock
  import tensorflow
  import tensorflow_datasets
  from tensorflow_datasets import testing
  from tensorflow_datasets.core import example_parser
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import reader
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core import writer
  from tensorflow_datasets.core.utils import read_config
  from tensorflow_datasets.core.utils import shard_utils
label_desc: Use image node_id 1 for calling a global function with example usage: _write_tfrecord_from_shard_spec(shard_spec, get) without return types