code: def test_inner_format():
      rla = topn.RecListAnalysis()
  
      recs = pd.DataFrame(
          {
              "data": "a",
              "user": ["a", "a", "a", "b", "b"],
              "item": [2, 3, 1, 4, 5],
              "rank": [1, 2, 3, 1, 2],
          }
      )
      truth = pd.DataFrame(
          {
              "user": ["a", "a", "a", "b", "b", "b"],
              "item": [1, 2, 3, 1, 5, 6],
              "rating": [3.0, 5.0, 4.0, 3.0, 5.0, 4.0],
          }
      )
  
      def inner(recs, truth, foo="a"):
          assert foo == "b"
          assert set(recs.columns) == set(
              ["LKRecID", "LKTruthID", "item", "rank"]
          )
          assert truth.index.name == "item"
          assert truth.index.is_unique
          print(truth)
          assert all(truth.columns == ["rating"])
          return len(recs.join(truth, on="item", how="inner"))
  
      rla.add_metric(inner, name="bob", foo="b")
  
      res = rla.compute(recs, truth)
      print(res)
  
      assert len(res) == 2
      assert res.index.nlevels == 2
      assert res.index.names == ["data", "user"]
      assert all(res.index.levels[0] == "a")
      assert all(res.index.levels[1] == ["a", "b"])
      assert all(res.reset_index().user == ["a", "b"])
      assert all(res["bob"] == [3, 1])
  
imports: from pathlib import Path
  import logging
  import numpy
  import pandas
  from pytest import approx, mark
  from lenskit.algorithms.user_knn import UserUser
  from lenskit.algorithms.item_knn import ItemItem
  from lenskit.algorithms.basic import PopScore
  from lenskit.algorithms.ranking import PlackettLuce
  from lenskit.algorithms import Recommender
  from lenskit.util.test import ml_test, demo_recs
  from lenskit.metrics.topn import _dcg, precision, recall
  from lenskit import topn, batch, crossfold
label_desc: Use image node_id 5 for calling a global function with example usage: test_inner_format() and returns: len