def _choose_meta_graph_def_internal(saved_model, tags):
  """Find a MetaGraphDef within the SavedModel with exactly matching tags.

  Args:
    saved_model: A `SavedModel` protocol buffer.
    tags: Set of string tags to identify the required MetaGraphDef. These should
        correspond to the tags used when saving the variables using the
        SavedModel `save()` API.
  Returns:
    The chosen `MetaGraphDef` protocol buffer.  This can be used to further
    extract signature-defs, collection-defs, etc. If tags cannot be found,
    returns None.
  """
  result = None
  for meta_graph_def in saved_model.meta_graphs:
    if set(meta_graph_def.meta_info_def.tags) == set(tags):
      result = meta_graph_def
      break

  return result