def METHOD_NAME(self, opt, dict_, null_idx, reduction_type, for_context: bool):
    """
    Return encoder that allows for image features to be passed in, given options.
    :param opt:
        opt dict
    :param dict:
        dictionary agent
    :param null_idx:
        null/pad index into dict
    :param reduction_type: only used for compatibility with the superclass method
    :param for_context:
        whether this is the context encoder (as opposed to the candidate encoder)
    :return:
        either a TransformerEncoder or a ContextWithImageEncoder, initialized
        correctly
    """
    if for_context:
        if reduction_type is not None:
            raise NotImplementedError('No encoder output reductions supported!')
        embeddings = self._get_embeddings(
            dict_=dict_, null_idx=null_idx, embedding_size=opt['embedding_size']
        )
        return ContextWithImageEncoder(
            opt=opt,
            vocabulary_size=len(dict_),
            embedding=embeddings,
            padding_idx=null_idx,
            image_encoder_num_layers=opt['image_encoder_num_layers'],
            image_features_dim=opt['image_features_dim'],
            image_combination_mode=opt['image_combination_mode'],
            n_image_tokens=opt['n_image_tokens'],
        )
    else:
        # The candidate encoder is the same as for PolyEncoderModule
        return super().METHOD_NAME(
            opt=opt,
            dict_=dict_,
            null_idx=null_idx,
            reduction_type=reduction_type,
            for_context=for_context,
        )