def METHOD_NAME(
    client_class,
    use_mtls,
    transport_name="grpc",
    channel_creator=grpc.insecure_channel,
):
    if use_mtls:
        with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}):
            with mock.patch("grpc.ssl_channel_credentials", autospec=True) as mock_ssl_cred:
                mock_ssl_cred.return_value = ssl_credentials
                client = client_class(
                    credentials=credentials.AnonymousCredentials(),
                    client_options=client_options,
                )
                mock_ssl_cred.assert_called_once_with(
                    certificate_chain=cert, private_key=key
                )
                return client
    else:
        transport_cls = client_class.get_transport_class(transport_name)
        if transport_name in ["grpc", "grpc_asyncio"]:
            transport = transport_cls(
                credentials=credentials.AnonymousCredentials(),
                channel=channel_creator("localhost:7469"),
            )
        elif transport_name == "rest":
            # The custom host explicitly bypasses https.
            transport = transport_cls(
                credentials=credentials.AnonymousCredentials(),
                host="localhost:7469",
                url_scheme="http",
            )
        else:
            raise RuntimeError(f"Unexpected transport type: {transport_name}")
        return client_class(transport=transport)