code: def test_by(self, by, doc_en):
      result = extract.to_bag_of_terms(doc_en, by=by, ngs=2)
      assert isinstance(result, dict)
      if by.endswith("_"):
          assert all(isinstance(key, str) for key in result.keys())
      else:
          assert all(isinstance(key, int) for key in result.keys())
  
file_path: textacy/tests/extract/test_bags.py
imports: import pytest
  import spacy
  from textacy import extract
label_desc: Use image node_id 3 for calling the TestBagOfTerms obj's underlying member method code with example usage: obj.test_by(by, doc_en) without return types