code: def write_targets_and_examples(summary_dir, targets, datasets):
      """Writes plaintext targets and inputs to the summary directory.
  
      Args:
        summary_dir: str, directory to store plaintext targets and examples
        targets: dict, task_name -> targets for each task.
        datasets: dict, task_name -> tf.data.Dataset for each task.
      """
      if targets.keys() != datasets.keys():
          raise ValueError(
              "Targets and datasets must have the same tasks."
          )
  
      for task in targets.keys():
          targets_filename = os.path.join(
              summary_dir,
              "{}_targets".format(task),
          )
          write_lines_to_file(targets[task], targets_filename)
  
          inputs = []
          for ex in tfds.as_numpy(datasets[task]):
              if "inputs_pretokenized" in ex:
                  inputs.append(ex["inputs_pretokenized"])
              else:
                  inputs.append(ex["inputs"])
  
          inputs_filename = os.path.join(
              summary_dir, "{}_inputs".format(task)
          )
  
          write_lines_to_file(inputs, inputs_filename)
  
imports: import functools
  import os
  import re
  from typing import Any, Callable, Iterable, Mapping, MutableSequence, Optional, Sequence, Tuple, Union
  from absl import logging
  import gin
  import numpy
  import seqio
  import t5.data
  import tensorflow.compat.v1
  import tensorflow_datasets
  import typing_extensions
label_desc: Use image node_id 4 for calling a global function with example usage: write_targets_and_examples(summary_dir, targets, datasets) without return types