Convert tensorflow code to pytorch

If the input tensor becomes empty torch.max(), will give an error vs tf.reduce_max will give -inf.

Is there someway we can retain the same behavior as tf.

Example:
torch.max(torch.tensor([]))
RuntimeError: max(): Expected reduction dim to be specified for input.numel() == 0. Specify the reduction dim with the ‘dim’ argument.

tf.reduce_max(tf.constant([]))
<tf.Tensor: shape=(), dtype=float32, numpy=-inf>