Call rust function in python

I want to write a rust function that takes the python tokenizer (the tokenizer might be set in python code). for example,
define this in rust

fn foo(tokenizer: PyTokenizer, ...) { ... }

and call it in python

tokenizer = AutoTokenizer.from_pretrained(...)
# set tokenizer, e.g. pad_id
foo(tokenizer, ...)

Is there any guide to achieve this