<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ipv4(self, network=False, address_class=None, private=None):
 """ Produce a random IPv4 address or network with a valid CIDR. :param network: Network address :param address_class: IPv4 address class (a, b, or c) :param private: Public or private :returns: IPv4 """

        if private is True:
            return self.ipv4_private(address_class=address_class,
                                     network=network)
        elif private is False:
            return self.ipv4_public(address_class=address_class,
                                    network=network)

        # if neither private nor public is required explicitly,
        # generate from whole requested address space
        if address_class:
            all_networks = [_IPv4Constants._network_classes[address_class]]
        else:
            # if no address class is choosen, use whole IPv4 pool
            all_networks = [ip_network('0.0.0.0/0')]

        # exclude special networks
        all_networks = self._exclude_ipv4_networks(
            all_networks,
            _IPv4Constants._excluded_networks,
        )

        # choose random network from the list
        random_network = self.generator.random.choice(all_networks)

        return self._random_ipv4_address_from_subnet(random_network, network)