code: def get_constants(
      values: Union[Number, Iterator[Number]],
      device: Optional[torch.device] = None,
      dtype: Optional[torch.dtype] = None,
  ) -> Union[Tensor, Tuple[Tensor, ...]]:
      r"""Returns scalar-valued Tensors containing each of the given constants.
      Used to expedite tensor operations involving scalar arithmetic. Note that
      the returned Tensors should not be modified in-place."""
      if isinstance(values, Number):
          return torch.full((), values, dtype=dtype, device=device)
  
      return tuple(
          torch.full((), val, dtype=dtype, device=device)
          for val in values
      )
  
imports: from __future__ import annotations
  import math
  from functools import lru_cache
  from math import pi
  from numbers import Number
  from typing import Any, Callable, Iterable, Iterator, Optional, Tuple, Union
  import torch
  from botorch.utils.safe_math import logdiffexp
  from numpy.polynomial.legendre import leggauss
  from torch import BoolTensor, LongTensor, Tensor
label_desc: Use image node_id 2 for calling a global function with example usage: get_constants(values, device, dtype) and returns: tuple, torch