def evaluate(tensor: BKTensor) -> TensorLike:
    """Return the value of a tensor"""
    if isinstance(tensor, _DTYPE):
        if torch.numel(tensor) == 1:
            return tensor.item()
        if tensor.numel() == 2:
            return tensor[0].cpu().numpy() + 1.0j * tensor[1].cpu().numpy()

        return tensor[0].cpu().numpy() + 1.0j * tensor[1].cpu().numpy()
    return tensor
def evaluate ( tensor : BKTensor ) -> TensorLike : if isinstance ( tensor , _DTYPE ) : if torch . numel ( tensor ) == 1 : return tensor . item ( ) if tensor . numel ( ) == 2 : return tensor [ 0 ] . cpu ( ) . numpy ( ) + 1.0j * tensor [ 1 ] . cpu ( ) . numpy ( ) return tensor [ 0 ] . cpu ( ) . numpy ( ) + 1.0j * tensor [ 1 ] . cpu ( ) . numpy ( ) return tensor
Return the value of a tensor