class_docstr: Writes a cache object that can be read by ReadAnalysisCacheFromFS.
  
  Given a cache collection, this writes it to the configured directory.
  If the configured directory already contains cache, this will merge the new
  cache with the old.
  NOTE: This merging of cache is determined at beam graph construction time,
  so the cache must already exist there when constructing this.
class_docstr_tok: ["Writes","a","cache","object","that","can","be","read","by","ReadAnalysisCacheFromFS",".","Given","a","cache","collection",",","this","writes","it","to","the","configured","directory",".","If","the","configured","directory","already","contains","cache",",","this","will","merge","the","new","cache","with","the","old",".","NOTE",":","This","merging","of","cache","is","determined","at","beam","graph","construction","time",",","so","the","cache","must","already","exist","there","when","constructing","this","."]
code: def expand(self, dataset_cache_dict):
      if self._sorted_dataset_keys is None:
          sorted_dataset_keys_list = sorted(dataset_cache_dict.keys())
      else:
          sorted_dataset_keys_list = self._sorted_dataset_keys
          missing_keys = set(dataset_cache_dict.keys()).difference(
              set(sorted_dataset_keys_list)
          )
          if missing_keys:
              raise ValueError(
                  "The dataset keys in the cache dictionary must be a subset of the "
                  "keys in dataset_keys. Missing {}.".format(
                      missing_keys
                  )
              )
      if not all(
          isinstance(d, DatasetKey) for d in sorted_dataset_keys_list
      ):
          raise ValueError(
              "Expected dataset_keys to be of type DatasetKey"
          )
  
      cache_is_written = []
      for dataset_key, cache in dataset_cache_dict.items():
          dataset_key_idx = sorted_dataset_keys_list.index(dataset_key)
          dataset_key_dir = _get_dataset_cache_path(
              self._cache_base_dir, dataset_key
          )
          with _ManifestFile(dataset_key_dir) as manifest_file:
              cache_is_written.extend(
                  self._write_cache(
                      manifest_file,
                      dataset_key_idx,
                      dataset_key_dir,
                      cache,
                  )
              )
  
      return cache_is_written
  
imports: import os
  import pickle
  import re
  import sys
  from typing import Iterable, Mapping, List, Optional, Union, Tuple
  import apache_beam
  import tensorflow
  from tfx_bsl.types import tfx_namedtuple
label_desc: Use image node_id 4 for calling the WriteAnalysisCacheToFS obj's underlying member method code with example usage: obj.expand(dataset_cache_dict) and returns: cache_is_written