code: def test_can_construct_from_params(self):
      params = Params(
          {
              "embedding_dim": 5,
              "num_filters": 4,
              "ngram_filter_sizes": [3, 5],
          }
      )
      encoder = CnnEncoder.from_params(params)
      assert encoder.get_output_dim() == 8
      params = Params(
          {
              "embedding_dim": 5,
              "num_filters": 4,
              "ngram_filter_sizes": [3, 5],
              "output_dim": 7,
          }
      )
      encoder = CnnEncoder.from_params(params)
      assert encoder.get_output_dim() == 7
  
file_path: allennlp/tests/modules/seq2vec_encoders/cnn_encoder_test.py
imports: import numpy
  from numpy.testing import assert_almost_equal
  import torch
  from allennlp.common import Params
  from allennlp.modules.seq2vec_encoders import CnnEncoder
  from allennlp.nn import InitializerApplicator, Initializer
  from allennlp.common.testing import AllenNlpTestCase
label_desc: Use image node_id 2 for calling the TestCnnEncoder obj's underlying member method code with example usage: obj.test_can_construct_from_params() without return types