code: def GetOutputPluginIndex(
      plugin_descriptors,
      plugin_id):
    
  
    used_names = collections.Counter()
    for (index, desc) in enumerate(plugin_descriptors):
      cur_plugin_id = "%s_%d" % (desc.plugin_name, used_names[desc.plugin_name])
      used_names[desc.plugin_name] += 1
  
      if cur_plugin_id == plugin_id:
        return index
  
    raise OutputPluginNotFoundError("Can't find output plugin %s" % plugin_id)
docs: Gets an output plugin index for a plugin with a given id.
  
    Historically output plugins descriptors were stored in dicts-like
    structures with unique identifiers as keys. In REL_DB-based implementation,
    however, both plugin descriptors and their states are stored in flat
    lists (see Flow definition in flows.proto).
  
    The ids were formed as "<plugin name>_<plugin index>" where plugin index
    was incremented for every plugin with a same name. For example, if we had
    EmailOutputPlugin and 2 BigQueryOutputPlugins, their ids would be:
    EmailOutputPlugin_0, BigQueryOutputPlugin_0, BigQueryOutputPlugin_1.
  
    To preserve backwards API compatibility, we emulate the old behavior by
    identifying plugins with same plugin ids as before..
  
    Args:
      plugin_descriptors: An iterable of OutputPluginDescriptor objects.
      plugin_id: Plugin id to search for.
  
    Returns:
      An index of a plugin in plugin_descriptors iterable corresponding to a
      given plugin_id.
  
    Raises:
      OutputPluginNotFoundError: if no plugin corresponding to a given plugin_id
      was found.