Based on the error message it seems you are passing a Tensor to splitext, which expects a str, bytes or os.PathLike object instead.
Check impath and make sure it’s one of the expected types.
PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier.