class_docstr: A DoFn that performs per-slice key fanout prior to computing aggregates.
class_docstr_tok: ["A","DoFn","that","performs","per-slice","key","fanout","prior","to","computing","aggregates","."]
code: def __init__(self, key_filter_fn: Callable[[str], bool]):
      self._num_slices_generated_per_instance = (
          beam.metrics.Metrics.distribution(
              constants.METRICS_NAMESPACE,
              "num_slices_generated_per_instance",
          )
      )
      self._post_slice_num_instances = beam.metrics.Metrics.counter(
          constants.METRICS_NAMESPACE, "post_slice_num_instances"
      )
      self._key_filter_fn = key_filter_fn
  
imports: import itertools
  from typing import Any, Callable, Dict, Generator, Iterable, List, NamedTuple, Optional, Tuple, Union
  import apache_beam
  import numpy
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.proto import metrics_for_slice_pb2
  from tensorflow_model_analysis.slicer import slice_accessor
label_desc: Use image node_id 1 to create a new _FanoutSlicesDoFn object from inherited base classes: beam with example: obj = _FanoutSlicesDoFn(key_filter_fn)