//  [python]
def _from_saved_model_v2(model_path, input_names, output_names, tag, signature_def,
                         concrete_function_index, large_model, use_graph_names):
    """Load tensorflow graph from saved_model."""

    wrn_no_tag = "'--tag' not specified for saved_model. Using --tag serve"
    wrn_empty_tag = "'--tag' value is empty string. Using tag =[[]]"
    wrn_sig_1 = "'--signature_def' not specified, using first signature: %s"
    err_many_sig = "Cannot load multiple signature defs in TF2.x: %s"
    err_no_call = "Model doesn't contain usable concrete functions under  __call__. Try --signature-def instead."
    err_index = "Invalid concrete_function value: %i. Valid values are [0 to %i]"
    err_no_sig = "No signatures found in model. Try --concrete_function instead."
    err_sig_nomatch = "Specified signature not in model %s"

    if tag is None:
        tag = ['serve']
        logger.warning(wrn_no_tag)

    if tag == '':
        tag = [[]]
        logger.warning(wrn_empty_tag)

    utils.make_sure(len(signature_def) < 2, err_many_sig, str(signature_def))
    imported = tf.compat.v1.saved_model.load(model_path, tags=tag)  # pylint: disable=no-value-for-parameter

    all_sigs = imported.signatures.keys()
    valid_sigs = [s for s in all_sigs if not s.startswith("_")]
    logger.info("Signatures found in model: %s", "[" + ",".join(valid_sigs) + "].")

    concrete_func = None
    if concrete_function_index is not None:
        utils.make_sure(hasattr(imported, "__call__"), err_no_call)
        utils.make_sure(concrete_function_index < len(imported.__call__.concrete_functions),
                        err_index, concrete_function_index, len(imported.__call__.concrete_functions) - 1)
        args, kwargs = imported.__call__.concrete_functions[concrete_function_index].structured_input_signature
        concrete_func = imported.__call__.get_concrete_function(*args, **kwargs)
    elif signature_def:
        utils.make_sure(signature_def[0] in valid_sigs, err_sig_nomatch, signature_def[0])
        concrete_func = imported.signatures[signature_def[0]]
    else:
        utils.make_sure(len(valid_sigs) > 0, err_no_sig)
        logger.warning(wrn_sig_1, valid_sigs[0])
        concrete_func = imported.signatures[valid_sigs[0]]

    tensors_to_rename = {}
    if input_names is None:
        inputs = [tensor.name for tensor in concrete_func.inputs if tensor.dtype != tf.dtypes.resource]
        if hasattr(concrete_func.graph, '_captures'):
            graph_captures = concrete_func.graph._captures  # pylint: disable=protected-access
            captured_inputs = [t_name.name for _, t_name in graph_captures.values()]
        else:
            graph_captures = concrete_func.graph.function_captures.by_val_internal
            captured_inputs = [t.name for t in graph_captures.values()]
        inputs = [inp for inp in inputs if inp not in captured_inputs]
        if concrete_func.structured_input_signature is not None and not use_graph_names:
            flat_structured_inp = tf.nest.flatten(concrete_func.structured_input_signature)
            structured_inputs = [t.name for t in flat_structured_inp if isinstance(t, tf.TensorSpec)]
            tensors_to_rename.update(zip(inputs, structured_inputs))
    else:
        inputs = input_names

    if output_names is None:
        outputs = [tensor.name for tensor in concrete_func.outputs if tensor.dtype != tf.dtypes.resource]
        if isinstance(concrete_func.structured_outputs, dict) and not use_graph_names:
            # outputs are sorted, sort structured_outputs the same way
            structured_outputs = sorted(concrete_func.structured_outputs.keys())
            tensors_to_rename.update(zip(outputs, structured_outputs))
            logger.info("Output names: %r", structured_outputs)
        else:
            logger.info("Output names: %r", outputs)
    else:
        outputs = output_names

    frozen_graph, initialized_tables = from_trackable(imported, concrete_func, inputs, outputs, large_model)

    return frozen_graph, inputs, outputs, concrete_func, imported, initialized_tables, tensors_to_rename