code: def test_build_features():
      users, items = 10, 100
  
      dataset = Dataset(
          user_identity_features=False, item_identity_features=False
      )
      dataset.fit(
          range(users),
          range(items),
          ["user:{}".format(x) for x in range(users)],
          ["item:{}".format(x) for x in range(items)],
      )
  
      # Build from lists
      user_features = dataset.build_user_features(
          [
              (user_id, ["user:{}".format(x) for x in range(users)])
              for user_id in range(users)
          ]
      )
      assert user_features.getnnz() == users**2
  
      item_features = dataset.build_item_features(
          [
              (item_id, ["item:{}".format(x) for x in range(items)])
              for item_id in range(items)
          ]
      )
      assert item_features.getnnz() == items**2
  
      # Build from dicts
      user_features = dataset.build_user_features(
          [
              (
                  user_id,
                  {"user:{}".format(x): float(x) for x in range(users)},
              )
              for user_id in range(users)
          ],
          normalize=False,
      )
  
      assert np.all(
          user_features.todense()
          == np.array([list(range(users))] * users)
      )
  
      item_features = dataset.build_item_features(
          [
              (
                  item_id,
                  {"item:{}".format(x): float(x) for x in range(items)},
              )
              for item_id in range(items)
          ],
          normalize=False,
      )
  
      assert np.all(
          item_features.todense()
          == np.array([list(range(items))] * items)
      )
  
      # Test normalization
      item_features = dataset.build_item_features(
          [
              (
                  item_id,
                  {"item:{}".format(x): float(x) for x in range(items)},
              )
              for item_id in range(items)
          ]
      )
  
      assert np.all(item_features.sum(1) == 1.0)
  
imports: import numpy
  import pytest
  from lightfm.data import Dataset
label_desc: Use image node_id 4 for calling a global function with example usage: test_build_features() without return types