code: def test_create_block_lexicon():
      vocab = {
          "test": 0,
          "TeSt": 1,
          "foo": 2,
          "bar": 3,
      }
      block_tokens = ["TeSt", "bar"]
      irrelevant_src_ids = np.array([1, 2, 3, 4])
  
      with TemporaryDirectory(
          prefix="test_create_block_lexicon."
      ) as work_dir:
          out_path = os.path.join(work_dir, "input.lex")
          sockeye.lexicon.create_block_lexicon(
              block_tokens, vocab, output_path=out_path, lowercase=False
          )
  
          lexicon = sockeye.lexicon.load_restrict_lexicon(out_path)
          expected = np.array([1, 3], dtype=np.int32)
          assert np.all(lexicon.lex == expected)
          assert np.all(lexicon.get_blocked_trg_ids() == expected)
          assert np.all(
              lexicon.get_blocked_trg_ids(irrelevant_src_ids)
              == expected
          )
  
      with TemporaryDirectory(
          prefix="test_create_block_lexicon."
      ) as work_dir:
          out_path = os.path.join(work_dir, "input.lex")
          sockeye.lexicon.create_block_lexicon(
              block_tokens, vocab, output_path=out_path, lowercase=True
          )
  
          lexicon = sockeye.lexicon.load_restrict_lexicon(out_path)
          expected = np.array([0, 1, 3], dtype=np.int32)
          assert np.all(lexicon.lex == expected)
          assert np.all(lexicon.get_blocked_trg_ids() == expected)
          assert np.all(
              lexicon.get_blocked_trg_ids(irrelevant_src_ids)
              == expected
          )
  
imports: import os
  from tempfile import TemporaryDirectory
  import numpy
  import sockeye.constants
  import sockeye.lexicon
label_desc: Use image node_id 2 for calling a global function with example usage: test_create_block_lexicon() without return types