in libtorch we can do :
    std::stringstream stream;
    torch::save(tensor, stream);
    return stream.str();
}

and get a byte-str and then can serialize it using protobuf for example. How can I do its equivalent in Pytorch?
would using io.BytesIO suffice?
import io 
 buffer = io.BytesIO()
torch.save(my_tensor, buffer)
bytes = buffer.read()
# use bytes ...

Any help is greatly apprecaited