docs: def cluster_on_extra_high_voltage(network, busmap, with_time=True):
      """ Main function of the EHV-Clustering approach. Creates a new clustered
      pypsa.Network given a busmap mapping all bus_ids to other bus_ids of the
      same network.
  
      Parameters
      ----------
      network : pypsa.Network
          Container for all network components.
  
      busmap : dict
          Maps old bus_ids to new bus_ids.
  
      with_time : bool
          If true time-varying data will also be aggregated.
  
      Returns
      -------
      network : pypsa.Network
          Container for all network components of the clustered network.
      """
  
      network_c = Network()
  
      buses = aggregatebuses(
          network, busmap, {
              'x': _leading(
                  busmap, network.buses), 'y': _leading(
                  busmap, network.buses)})
  
      # keep attached lines
      lines = network.lines.copy()
      mask = lines.bus0.isin(buses.index)
      lines = lines.loc[mask, :]
  
      # keep attached links
      links = network.links.copy()
      mask = links.bus0.isin(buses.index)
      links = links.loc[mask, :]
  
      # keep attached transformer
      transformers = network.transformers.copy()
      mask = transformers.bus0.isin(buses.index)
      transformers = transformers.loc[mask, :]
  
      io.import_components_from_dataframe(network_c, buses, "Bus")
      io.import_components_from_dataframe(network_c, lines, "Line")
      io.import_components_from_dataframe(network_c, links, "Link")
      io.import_components_from_dataframe(network_c, transformers, "Transformer")
  
      if with_time:
          network_c.snapshots = network.snapshots
          network_c.set_snapshots(network.snapshots)
          network_c.snapshot_weightings = network.snapshot_weightings.copy()
  
      # dealing with generators
      network.generators.control = "PV"
      network.generators['weight'] = 1
      new_df, new_pnl = aggregategenerators(network, busmap, with_time)
      io.import_components_from_dataframe(network_c, new_df, 'Generator')
      for attr, df in iteritems(new_pnl):
          io.import_series_from_dataframe(network_c, df, 'Generator', attr)
  
      # dealing with all other components
      aggregate_one_ports = components.one_port_components.copy()
      aggregate_one_ports.discard('Generator')
  
      for one_port in aggregate_one_ports:
          new_df, new_pnl = aggregateoneport(
              network, busmap, component=one_port, with_time=with_time)
          io.import_components_from_dataframe(network_c, new_df, one_port)
          for attr, df in iteritems(new_pnl):
              io.import_series_from_dataframe(network_c, df, one_port, attr)
  
      network_c.determine_network_topology()
  
      return network_c