Does PyTorch provide a context manager to specify the dtype and device for all new tensors created inside that context? Roughly, I’m looking for something like:
# `input` is an existing `torch.Tensor`
with default_device_and_dtype(input):   # <-- is there a context manager like this somewhere?
  x = torch.empty(1,2,3)
  y = torch.zeros(4,5)

# expected: `x` and `y` are `torch.Tensor`s with the same dtype and device as `input`