Hello,
Does this function solve your problem?
import random

def get_rand_value(tensor):
    number_of_elements = tensor.numel()
    random_element_number = random.randrange(number_of_elements)
    value_of_random_element = tensor.flatten()[random_element_number]
    return value_of_random_element

Regards,
Thomas