class_docstr: Specification for a single slice.
  
  This is intended to be an immutable class that specifies a single slice.
  Use this in conjunction with get_slices_for_features_dicts to generate slices
  for dictionaries of features.
  
  Examples:
    - columns = ['age'], features = []
      This means to slice by the 'age' column.
    - columns = ['age'], features = [('gender', 'female')]
      This means to slice by the 'age' column if the 'gender' is 'female'.
    - For more examples, refer to the tests in slicer_test.py.
class_docstr_tok: ["Specification","for","a","single","slice",".","This","is","intended","to","be","an","immutable","class","that","specifies","a","single","slice",".","Use","this","in","conjunction","with","get_slices_for_features_dicts","to","generate","slices","for","dictionaries","of","features",".","Examples",":","-","columns","=","[","'age","'","]",",","features","=","[","]","This","means","to","slice","by","the","'age","'","column",".","-","columns","=","[","'age","'","]",",","features","=","[","(","'gender","'",",","'female","'",")","]","This","means","to","slice","by","the","'age","'","column","if","the","'gender","'","is","'female","'",".","-","For","more","examples",",","refer","to","the","tests","in","slicer_test.py","."]
docstr: Initialises a SingleSliceSpec.
  
  Args:
    columns: an iterable of column names to slice on.
    features: an iterable of features to slice on. Each feature is a (key,
      value) tuple. Note that strings representing ints and floats will be
      automatically converted to ints and floats respectively and will be
      compared against both the string versions and int or float versions of
      the associated features.
    spec: Initializes slicing spec from proto. If not None, overrides any
      values passed in columns or features.
  
  Raises:
    ValueError: There was overlap between the columns specified in columns
      and those in features.
    ValueError: columns or features was a string: they should probably be a
      singleton list containing that string.
code: def __init__(
      self,
      columns: Iterable[str] = (),
      features: Iterable[Tuple[str, FeatureValueType]] = (),
      spec: Optional[config_pb2.SlicingSpec] = None,
  ):
      """Initialises a SingleSliceSpec.
  
      Args:
        columns: an iterable of column names to slice on.
        features: an iterable of features to slice on. Each feature is a (key,
          value) tuple. Note that strings representing ints and floats will be
          automatically converted to ints and floats respectively and will be
          compared against both the string versions and int or float versions of
          the associated features.
        spec: Initializes slicing spec from proto. If not None, overrides any
          values passed in columns or features.
  
      Raises:
        ValueError: There was overlap between the columns specified in columns
          and those in features.
        ValueError: columns or features was a string: they should probably be a
          singleton list containing that string.
      """
      if isinstance(columns, str):
          raise ValueError(
              "columns is a string: it should probably be a singleton "
              "list containing that string"
          )
      if isinstance(features, str):
          raise ValueError(
              "features is a string: it should probably be a "
              "singleton list containing that string"
          )
  
      if spec is not None:
          columns = spec.feature_keys
          features = [(k, v) for k, v in spec.feature_values.items()]
  
      features = [(k, _to_type(v)) for (k, v) in features]
  
      self._columns = frozenset(columns)
      self._features = frozenset(features)
  
      # We build this up as an instance variable, instead of building it each
      # time we call generate_slices, for efficiency reasons.
      #
      # This is a flat list of SingletonSliceKeyTypes,
      # i.e. List[SingletonSliceKeyType].
      self._value_matches = []
  
      for key, value in self._features:
          if key in self._columns:
              raise ValueError(
                  "Columns specified in columns and in features should "
                  "not overlap, but %s was specified in both." % key
              )
          self._value_matches.append((key, value))
      self._value_matches = sorted(self._value_matches)
  
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 4 to create a new SingleSliceSpec object  with example: obj = SingleSliceSpec(columns, features, spec)