def _random_ipv4_address_from_subnets(
        self,
        subnets: List[IPv4Network],
        weights: Optional[List[int]] = None,
        network: bool = False,
    ) -> str:
        """
        Produces a random IPv4 address or network with a valid CIDR
        from within the given subnets using a distribution described
        by weights.

        :param subnets: List of IPv4Networks to choose from within
        :param weights: List of weights corresponding to the individual IPv4Networks
        :param network: Return a network address, and not an IP address
        :return:
        """
        if not subnets:
            raise ValueError("No subnets to choose from")

        # If the weights argument has an invalid value, default to equal distribution
        if (
            isinstance(weights, list)
            and len(subnets) == len(weights)
            and all(isinstance(w, (float, int)) for w in weights)
        ):
            subnet = choices_distribution(
                subnets,
                [float(w) for w in weights],
                random=self.generator.random,
                length=1,
            )[0]
        else:
            subnet = self.generator.random.choice(subnets)

        address = str(
            subnet[
                self.generator.random.randint(
                    0,
                    subnet.num_addresses - 1,
                )
            ],
        )

        if network:
            address += "/" + str(
                self.generator.random.randint(
                    subnet.prefixlen,
                    subnet.max_prefixlen,
                )
            )
            address = str(IPv4Network(address, strict=False))

        return address

        Produces a random IPv4 address or network with a valid CIDR
        from within the given subnets using a distribution described
        by weights.

        :param subnets: List of IPv4Networks to choose from within
        :param weights: List of weights corresponding to the individual IPv4Networks
        :param network: Return a network address, and not an IP address
        :return:
        
faker/providers/internet/__init__.py