def run_model_analysis(eval_shared_model: Optional[Union[(types.EvalSharedModel, Dict[(Text, types.EvalSharedModel)])]]=None, eval_config: config.EvalConfig=None, data_location: Text='', file_format: Text='tfrecords', output_path: Optional[Text]=None, extractors: Optional[List[extractor.Extractor]]=None, evaluators: Optional[List[evaluator.Evaluator]]=None, writers: Optional[List[writer.Writer]]=None, pipeline_options: Optional[Any]=None, slice_spec: Optional[List[slicer.SingleSliceSpec]]=None, write_config: Optional[bool]=True, compute_confidence_intervals: Optional[bool]=False, k_anonymization_count: int=1, desired_batch_size: Optional[int]=None, random_seed_for_testing: Optional[int]=None) -> Union[(EvalResult, EvalResults)]:
    "Runs TensorFlow model analysis.\n\n  It runs a Beam pipeline to compute the slicing metrics exported in TensorFlow\n  Eval SavedModel and returns the results.\n\n  This is a simplified API for users who want to quickly get something running\n  locally. Users who wish to create their own Beam pipelines can use the\n  Evaluate PTransform instead.\n\n  Args:\n    eval_shared_model: Optional shared model (single-model evaluation) or dict\n      of shared models keyed by model name (multi-model evaluation). Only\n      required if needed by default extractors, evaluators, or writers.\n    eval_config: Eval config.\n    data_location: The location of the data files.\n    file_format: The file format of the data, can be either 'text' or\n      'tfrecords' for now. By default, 'tfrecords' will be used.\n    output_path: The directory to output metrics and results to. If None, we use\n      a temporary directory.\n    extractors: Optional list of Extractors to apply to Extracts. Typically\n      these will be added by calling the default_extractors function. If no\n      extractors are provided, default_extractors (non-materialized) will be\n      used.\n    evaluators: Optional list of Evaluators for evaluating Extracts. Typically\n      these will be added by calling the default_evaluators function. If no\n      evaluators are provided, default_evaluators will be used.\n    writers: Optional list of Writers for writing Evaluation output. Typically\n      these will be added by calling the default_writers function. If no writers\n      are provided, default_writers will be used.\n    pipeline_options: Optional arguments to run the Pipeline, for instance\n      whether to run directly.\n    slice_spec: Deprecated (use EvalConfig).\n    write_config: Deprecated (use EvalConfig).\n    compute_confidence_intervals: Deprecated (use EvalConfig).\n    k_anonymization_count: Deprecated (use EvalConfig).\n    desired_batch_size: Optional batch size for batching in Predict.\n    random_seed_for_testing: Provide for deterministic tests only.\n\n  Returns:\n    An EvalResult that can be used with the TFMA visualization functions.\n\n  Raises:\n    ValueError: If the file_format is unknown to us.\n  "
    _assert_tensorflow_version()
    if (output_path is None):
        output_path = tempfile.mkdtemp()
    if (not tf.io.gfile.exists(output_path)):
        tf.io.gfile.makedirs(output_path)
    if (eval_config is None):
        model_specs = []
        eval_shared_models = eval_shared_model
        if (not isinstance(eval_shared_model, dict)):
            eval_shared_models = {'': eval_shared_model}
        for (model_name, shared_model) in eval_shared_models.items():
            example_weight_key = shared_model.example_weight_key
            example_weight_keys = {}
            if (example_weight_key and isinstance(example_weight_key, dict)):
                example_weight_keys = example_weight_key
                example_weight_key = ''
            model_specs.append(config.ModelSpec(name=model_name, example_weight_key=example_weight_key, example_weight_keys=example_weight_keys))
        slicing_specs = None
        if slice_spec:
            slicing_specs = [s.to_proto() for s in slice_spec]
        options = config.Options()
        options.compute_confidence_intervals.value = compute_confidence_intervals
        options.k_anonymization_count.value = k_anonymization_count
        if (not write_config):
            options.disabled_outputs.values.append(_EVAL_CONFIG_FILE)
        eval_config = config.EvalConfig(model_specs=model_specs, slicing_specs=slicing_specs, options=options)
    with beam.Pipeline(options=pipeline_options) as p:
        if (file_format == 'tfrecords'):
            data = (p | ('ReadFromTFRecord' >> beam.io.ReadFromTFRecord(file_pattern=data_location, compression_type=beam.io.filesystem.CompressionTypes.AUTO)))
        elif (file_format == 'text'):
            data = (p | ('ReadFromText' >> beam.io.textio.ReadFromText(data_location)))
        else:
            raise ValueError('unknown file_format: {}'.format(file_format))
        _ = (data | ('ExtractEvaluateAndWriteResults' >> ExtractEvaluateAndWriteResults(eval_config=eval_config, eval_shared_model=eval_shared_model, display_only_data_location=data_location, display_only_file_format=file_format, output_path=output_path, extractors=extractors, evaluators=evaluators, writers=writers, desired_batch_size=desired_batch_size, random_seed_for_testing=random_seed_for_testing)))
    if (len(eval_config.model_specs) <= 1):
        return load_eval_result(output_path)
    else:
        results = []
        for spec in eval_config.model_specs:
            results.append(load_eval_result(output_path, model_name=spec.name))
        return EvalResults(results, constants.MODEL_CENTRIC_MODE)
Runs TensorFlow model analysis.

It runs a Beam pipeline to compute the slicing metrics exported in TensorFlow
Eval SavedModel and returns the results.

This is a simplified API for users who want to quickly get something running
locally. Users who wish to create their own Beam pipelines can use the
Evaluate PTransform instead.

Args:
  eval_shared_model: Optional shared model (single-model evaluation) or dict
    of shared models keyed by model name (multi-model evaluation). Only
    required if needed by default extractors, evaluators, or writers.
  eval_config: Eval config.
  data_location: The location of the data files.
  file_format: The file format of the data, can be either 'text' or
    'tfrecords' for now. By default, 'tfrecords' will be used.
  output_path: The directory to output metrics and results to. If None, we use
    a temporary directory.
  extractors: Optional list of Extractors to apply to Extracts. Typically
    these will be added by calling the default_extractors function. If no
    extractors are provided, default_extractors (non-materialized) will be
    used.
  evaluators: Optional list of Evaluators for evaluating Extracts. Typically
    these will be added by calling the default_evaluators function. If no
    evaluators are provided, default_evaluators will be used.
  writers: Optional list of Writers for writing Evaluation output. Typically
    these will be added by calling the default_writers function. If no writers
    are provided, default_writers will be used.
  pipeline_options: Optional arguments to run the Pipeline, for instance
    whether to run directly.
  slice_spec: Deprecated (use EvalConfig).
  write_config: Deprecated (use EvalConfig).
  compute_confidence_intervals: Deprecated (use EvalConfig).
  k_anonymization_count: Deprecated (use EvalConfig).
  desired_batch_size: Optional batch size for batching in Predict.
  random_seed_for_testing: Provide for deterministic tests only.

Returns:
  An EvalResult that can be used with the TFMA visualization functions.

Raises:
  ValueError: If the file_format is unknown to us.
def run_model_analysis(eval_shared_model: Optional[Union[(types.EvalSharedModel, Dict[(Text, types.EvalSharedModel)])]]=None, eval_config: config.EvalConfig=None, data_location: Text=, file_format: Text='tfrecords', output_path: Optional[Text]=None, extractors: Optional[List[extractor.Extractor]]=None, evaluators: Optional[List[evaluator.Evaluator]]=None, writers: Optional[List[writer.Writer]]=None, pipeline_options: Optional[Any]=None, slice_spec: Optional[List[slicer.SingleSliceSpec]]=None, write_config: Optional[bool]=True, compute_confidence_intervals: Optional[bool]=False, k_anonymization_count: int=1, desired_batch_size: Optional[int]=None, random_seed_for_testing: Optional[int]=None) -> Union[(EvalResult, EvalResults)]:
    "Runs TensorFlow model analysis.\n\n  It runs a Beam pipeline to compute the slicing metrics exported in TensorFlow\n  Eval SavedModel and returns the results.\n\n  This is a simplified API for users who want to quickly get something running\n  locally. Users who wish to create their own Beam pipelines can use the\n  Evaluate PTransform instead.\n\n  Args:\n    eval_shared_model: Optional shared model (single-model evaluation) or dict\n      of shared models keyed by model name (multi-model evaluation). Only\n      required if needed by default extractors, evaluators, or writers.\n    eval_config: Eval config.\n    data_location: The location of the data files.\n    file_format: The file format of the data, can be either 'text' or\n      'tfrecords' for now. By default, 'tfrecords' will be used.\n    output_path: The directory to output metrics and results to. If None, we use\n      a temporary directory.\n    extractors: Optional list of Extractors to apply to Extracts. Typically\n      these will be added by calling the default_extractors function. If no\n      extractors are provided, default_extractors (non-materialized) will be\n      used.\n    evaluators: Optional list of Evaluators for evaluating Extracts. Typically\n      these will be added by calling the default_evaluators function. If no\n      evaluators are provided, default_evaluators will be used.\n    writers: Optional list of Writers for writing Evaluation output. Typically\n      these will be added by calling the default_writers function. If no writers\n      are provided, default_writers will be used.\n    pipeline_options: Optional arguments to run the Pipeline, for instance\n      whether to run directly.\n    slice_spec: Deprecated (use EvalConfig).\n    write_config: Deprecated (use EvalConfig).\n    compute_confidence_intervals: Deprecated (use EvalConfig).\n    k_anonymization_count: Deprecated (use EvalConfig).\n    desired_batch_size: Optional batch size for batching in Predict.\n    random_seed_for_testing: Provide for deterministic tests only.\n\n  Returns:\n    An EvalResult that can be used with the TFMA visualization functions.\n\n  Raises:\n    ValueError: If the file_format is unknown to us.\n  "
    _assert_tensorflow_version()
    if (output_path is None):
        output_path = tempfile.mkdtemp()
    if (not tf.io.gfile.exists(output_path)):
        tf.io.gfile.makedirs(output_path)
    if (eval_config is None):
        model_specs = []
        eval_shared_models = eval_shared_model
        if (not isinstance(eval_shared_model, dict)):
            eval_shared_models = {: eval_shared_model}
        for (model_name, shared_model) in eval_shared_models.items():
            example_weight_key = shared_model.example_weight_key
            example_weight_keys = {}
            if (example_weight_key and isinstance(example_weight_key, dict)):
                example_weight_keys = example_weight_key
                example_weight_key = 
            model_specs.append(config.ModelSpec(name=model_name, example_weight_key=example_weight_key, example_weight_keys=example_weight_keys))
        slicing_specs = None
        if slice_spec:
            slicing_specs = [s.to_proto() for s in slice_spec]
        options = config.Options()
        options.compute_confidence_intervals.value = compute_confidence_intervals
        options.k_anonymization_count.value = k_anonymization_count
        if (not write_config):
            options.disabled_outputs.values.append(_EVAL_CONFIG_FILE)
        eval_config = config.EvalConfig(model_specs=model_specs, slicing_specs=slicing_specs, options=options)
    with beam.Pipeline(options=pipeline_options) as p:
        if (file_format == 'tfrecords'):
            data = (p | ('ReadFromTFRecord' >> beam.io.ReadFromTFRecord(file_pattern=data_location, compression_type=beam.io.filesystem.CompressionTypes.AUTO)))
        elif (file_format == 'text'):
            data = (p | ('ReadFromText' >> beam.io.textio.ReadFromText(data_location)))
        else:
            raise ValueError('unknown file_format: {}'.format(file_format))
        _ = (data | ('ExtractEvaluateAndWriteResults' >> ExtractEvaluateAndWriteResults(eval_config=eval_config, eval_shared_model=eval_shared_model, display_only_data_location=data_location, display_only_file_format=file_format, output_path=output_path, extractors=extractors, evaluators=evaluators, writers=writers, desired_batch_size=desired_batch_size, random_seed_for_testing=random_seed_for_testing)))
    if (len(eval_config.model_specs) <= 1):
        return load_eval_result(output_path)
    else:
        results = []
        for spec in eval_config.model_specs:
            results.append(load_eval_result(output_path, model_name=spec.name))
        return EvalResults(results, constants.MODEL_CENTRIC_MODE)