code: def test_sample_categorical_serialize():
      """Check the random variable sampling results after schedule serialization"""
      n = 100
      sch = tir.Schedule(elementwise, seed=42, debug_mask="all")
      candidates = [5, 6, 7, 8]
      probs = [0.23, 0.19, 0.37, 0.21]
      decisions = []
      for _ in range(n):
          rv = sch.get(
              sch.sample_categorical(candidates, probs)
          )  # pylint: disable=invalid-name
          decisions.append(rv)
      new_sch = verify_trace_roundtrip(sch, mod=elementwise)
      for i, new_inst in enumerate(new_sch.trace.insts):
          assert (
              decisions[i]
              == candidates[new_sch.trace.decisions[new_inst].value]
          )
  
file_path: tvm/tests/python/tir-schedule/test_tir_schedule_sampling.py
imports: from collections import defaultdict
  import sys
  import numpy
  import pytest
  import tvm.testing
  from tvm import tir
  from tvm.script import tir
  from tvm.tir.schedule.testing import verify_trace_roundtrip
label_desc: Use image node_id 5 for calling a global function with example usage: test_sample_categorical_serialize() without return types