def check_no_duplicated_parameters(model: Any) -> None:
  """Checks that there are no duplicated parameters in a model.

  Args:
    model: An arbitrary model.

  Raises:
    ValueError: If two concrete parameters (parameters with a value) have the
    same name.
  """
  parameter_counts = collections.Counter(
      param.name
      for param in (
          selectors.select(model)
          .at_instances_of(Parameter | FrozenParameter | UninitializedParameter)
          .get_sequence()
      )
  )
  duplicates = [key for key, count in parameter_counts.items() if count > 1]
  if duplicates:
    raise ValueError(
        "Found multiple parameters with the same name! Repeated names:"
        f" {duplicates}"
    )
Checks that there are no duplicated parameters in a model.

  Args:
    model: An arbitrary model.

  Raises:
    ValueError: If two concrete parameters (parameters with a value) have the
    same name.
  
penzai/deprecated/v1/nn/parameters.py