Serializes `module_into`.

  Args:
    module_info: An instance of `ModuleInfo`.
    export_scope: Optional `string`. Name scope to remove.

  Returns:
    An instance of `module_pb2.SonnetModule`.

def _module_info_to_proto(module_info, export_scope=None):
  """Serializes `module_into`.

  Args:
    module_info: An instance of `ModuleInfo`.
    export_scope: Optional `string`. Name scope to remove.

  Returns:
    An instance of `module_pb2.SonnetModule`.
  """
  def strip_name_scope(name_scope):
    return ops.strip_name_scope(name_scope, export_scope)
  def process_leafs(value):
    return strip_name_scope(_graph_element_to_path(value))
  module_info_def = module_pb2.SonnetModule(
      module_name=module_info.module_name,
      scope_name=strip_name_scope(module_info.scope_name),
      class_name=module_info.class_name)
  for connected_subgraph in module_info.connected_subgraphs:
    connected_subgraph_info_def = module_info_def.connected_subgraphs.add()
    connected_subgraph_info_def.name_scope = strip_name_scope(
        connected_subgraph.name_scope)
    _nested_to_proto(
        connected_subgraph.inputs,
        connected_subgraph_info_def.inputs,
        process_leafs, set())
    _nested_to_proto(
        connected_subgraph.outputs,
        connected_subgraph_info_def.outputs,
        process_leafs, set())
  return module_info_def