code: def shared(
      value, name=None, strict=False, allow_downcast=None, **kwargs
  ):
      r"""Create a `SharedVariable` initialized with a copy or reference of `value`.
  
      This function iterates over constructor functions to find a
      suitable `SharedVariable` subclass.  The suitable one is the first
      constructor that accept the given value.  See the documentation of
      :func:`shared_constructor` for the definition of a constructor
      function.
  
      This function is meant as a convenient default.  If you want to use a
      specific constructor, consider calling it directly.
  
      `pytensor.shared` is a shortcut to this function.
  
      Notes
      -----
      By passing kwargs, you effectively limit the set of potential constructors
      to those that can accept those kwargs.
  
      Some shared variable have `borrow` as a kwarg.
  
      `SharedVariable`\s of `TensorType` have `broadcastable` as a kwarg. As shared
      variable shapes can change, all dimensions default to not being
      broadcastable, even if `value` has a shape of 1 along some dimension.
      This parameter allows one to create for example a row or column tensor.
  
      """
  
      if isinstance(value, Variable):
          raise TypeError("Shared variable values can not be symbolic.")
  
      try:
          var = shared_constructor(
              value,
              name=name,
              strict=strict,
              allow_downcast=allow_downcast,
              **kwargs,
          )
          add_tag_trace(var)
          return var
      except MemoryError as e:
          e.args = e.args + (
              "Consider using `pytensor.shared(..., borrow=True)`",
          )
          raise
  
file_path: pytensor/pytensor/compile/sharedvalue.py
imports: import copy
  from contextlib import contextmanager
  from functools import singledispatch
  from typing import TYPE_CHECKING, Optional
  from pytensor.graph.basic import Variable
  from pytensor.graph.utils import add_tag_trace
  from pytensor.link.basic import Container
  from pytensor.link.c.type import generic
label_desc: Use image node_id 2 for calling a global function with example usage: shared(value, name, strict, allow_downcast) and returns: var