code: def test_tfidf_encoder(vocab_size: int):
      # make repeatable
      torch.manual_seed(RANDOM_SEED)
  
      batch_size = 10
      sequence_length = 32
      vocab = [str(i) for i in range(1, vocab_size + 1)]
      str2idf = {s: 1 for s in vocab}
      text_encoder = text_encoders.TfIdfEncoder(
          max_sequence_length=sequence_length,
          str2idf=str2idf,
          vocab=vocab,
          vocab_size=vocab_size,
      ).to(DEVICE)
  
      assert len(text_encoder.output_shape) == 1
      assert text_encoder.output_shape[0] == vocab_size
      assert len(list(text_encoder.parameters())) == 0
  
      inputs = torch.randint(2, (batch_size, sequence_length)).to(
          DEVICE
      )
      outputs = text_encoder(inputs)
      assert (
          outputs[ENCODER_OUTPUT].shape[1:] == text_encoder.output_shape
      )
  
imports: import json
  import os
  from typing import Optional, Type, Union
  from unittest import mock
  import pytest
  import torch
  import ludwig.schema.encoders.utils
  from ludwig.api import LudwigModel
  from ludwig.constants import ENCODER, ENCODER_OUTPUT, MODEL_ECD, NAME, TEXT, TRAINER
  from ludwig.encoders import text_encoders
  from ludwig.error import ConfigValidationError
  from ludwig.globals import MODEL_HYPERPARAMETERS_FILE_NAME
  from ludwig.schema.model_config import ModelConfig
  from ludwig.utils.data_utils import load_json
  from ludwig.utils.torch_utils import get_torch_device
  from tests.integration_tests.parameter_update_utils import check_module_parameters_updated
  from tests.integration_tests.utils import category_feature, clear_huggingface_cache, generate_data, HF_ENCODERS, LocalTestBackend, text_feature
label_desc: Use image node_id 8 for calling a global function with example usage: test_tfidf_encoder(vocab_size) without return types