code: def scalar_constructor(
      value,
      name=None,
      strict=False,
      allow_downcast=None,
      borrow=False,
      target="cpu",
  ):
      """`SharedVariable` constructor for scalar values.
  
      Default: int64 or float64.
  
      Notes
      -----
      We implement this using 0-d tensors for now.
  
      We ignore the borrow parameter as we convert ``value`` to an
      ndarray (this is a new object). This respects the semantic of
      borrow, as it is a hint to PyTensor that we can reuse it.
  
      """
      if target != "cpu":
          raise TypeError("not for cpu")
  
      try:
          dtype = value.dtype
      except AttributeError:
          dtype = np.asarray(value).dtype
  
      dtype = str(dtype)
      value = _asarray(value, dtype=dtype)
      tensor_type = TensorType(dtype=str(value.dtype), shape=())
  
      # Do not pass the dtype to asarray because we want this to fail if
      # strict is True and the types do not match.
      rval = ScalarSharedVariable(
          type=tensor_type,
          value=np.array(value, copy=True),
          name=name,
          strict=strict,
          allow_downcast=allow_downcast,
      )
      return rval
  
file_path: pytensor/pytensor/tensor/sharedvar.py
imports: import warnings
  import numpy
  from pytensor.compile import SharedVariable, shared_constructor
  from pytensor.misc.safe_asarray import _asarray
  from pytensor.tensor import _get_vector_length
  from pytensor.tensor.type import TensorType
  from pytensor.tensor.variable import _tensor_py_operators
label_desc: Use image node_id 4 for calling a global function with example usage: scalar_constructor(value, name, strict, allow_downcast, borrow, target) and returns: rval