def build_encoder(gan_type, resolution, **kwargs):
    """Builds encoder by GAN type.

    Args:
        gan_type: GAN type to which the encoder belong.
        resolution: Input resolution for encoder.
        **kwargs: Additional arguments to build the encoder.

    Raises:
        ValueError: If the `gan_type` is not supported.
        NotImplementedError: If the `gan_type` is not implemented.
    """
    if gan_type not in _GAN_TYPES_ALLOWED:
        raise ValueError(f'Invalid GAN type: `{gan_type}`!\n'
                         f'Types allowed: {_GAN_TYPES_ALLOWED}.')

    if gan_type in ['stylegan', 'stylegan2']:
        return EncoderNet(resolution, **kwargs)

    raise NotImplementedError(f'Unsupported GAN type `{gan_type}` for encoder!')
Builds encoder by GAN type.

    Args:
        gan_type: GAN type to which the encoder belong.
        resolution: Input resolution for encoder.
        **kwargs: Additional arguments to build the encoder.

    Raises:
        ValueError: If the `gan_type` is not supported.
        NotImplementedError: If the `gan_type` is not implemented.
    
models/__init__.py