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 Theano that we can reuse it.
  
      """
      if target != "cpu":
          raise TypeError("not for cpu")
  
      if not isinstance(
          value, (np.number, float, integer_types, complex)
      ):
          raise TypeError()
      try:
          dtype = value.dtype
      except Exception:
          dtype = np.asarray(value).dtype
  
      dtype = str(dtype)
      value = theano._asarray(value, dtype=dtype)
      tensor_type = TensorType(dtype=str(value.dtype), broadcastable=[])
  
      try:
          # 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
      except Exception:
          traceback.print_exc()
          raise
  
file_path: Theano/theano/tensor/sharedvar.py
imports: from __future__ import absolute_import, print_function, division
  import traceback
  import numpy
  from six import integer_types
  import theano.tensor.basic
  from theano.tensor.basic import TensorType, _tensor_py_operators
  from theano.compile import shared_constructor, SharedVariable
label_desc: Use image node_id 3 for calling a global function with example usage: scalar_constructor(value, name, strict, allow_downcast, borrow, target) and returns: rval