class_docstr: Variable that is shared between compiled functions.
class_docstr_tok: ["Variable","that","is","shared","between","compiled","functions","."]
docstr: Parameters
  ----------
  type
      The `Type` for this variable (see `Variable`).
  value
      A value to associate with this variable (a new container will be
      created).
  strict
      ``True`` means that values assigned to this variable will not be
      cast or copied, so they must have the correct `Type`\s.
  allow_downcast
      Only applies if `strict` is ``False``.
      ``True`` means that the assigned value can lose precision when cast
      during assignment. ``None`` means that only down-casting of a Python
      float to a scalar ``floatX`` is allowed.
  container
      The container to use for this variable. Illegal to pass this as well as
      a value.
  name
      The name for this variable (see `Variable`).
docstr_tok: ["Parameters","--","--","--","--","--","type","The","`","Type","`","for","this","variable","(","see","`","Variable","`",")",".","value","A","value","to","associate","with","this","variable","(","a","new","container","will","be","created",")",".","strict","``","True","``","means","that","values","assigned","to","this","variable","will","not","be","cast","or","copied",",","so","they","must","have","the","correct","`","Type","`","\\s",".","allow_downcast","Only","applies","if","`","strict","`","is","``","False","``",".","``","True","``","means","that","the","assigned","value","can","lose","precision","when","cast","during","assignment",".","``","None","``","means","that","only","down-casting","of","a","Python","float","to","a","scalar","``","floatX","``","is","allowed",".","container","The","container","to","use","for","this","variable",".","Illegal","to","pass","this","as","well","as","a","value",".","name","The","name","for","this","variable","(","see","`","Variable","`",")","."]
code: def __init__(
      self,
      type: "Type",
      value,
      strict: bool,
      allow_downcast=None,
      container: Optional[Container] = None,
      name: Optional[str] = None,
  ):
      r"""
      Parameters
      ----------
      type
          The `Type` for this variable (see `Variable`).
      value
          A value to associate with this variable (a new container will be
          created).
      strict
          ``True`` means that values assigned to this variable will not be
          cast or copied, so they must have the correct `Type`\s.
      allow_downcast
          Only applies if `strict` is ``False``.
          ``True`` means that the assigned value can lose precision when cast
          during assignment. ``None`` means that only down-casting of a Python
          float to a scalar ``floatX`` is allowed.
      container
          The container to use for this variable. Illegal to pass this as well as
          a value.
      name
          The name for this variable (see `Variable`).
  
      """
      super().__init__(type=type, owner=None, index=None, name=name)
  
      if container is not None:
          self.container = container
          if (value is not None) or (strict is not None):
              raise TypeError(
                  "value and strict are ignored if you pass a container here"
              )
      else:
          self.container = Container(
              self,
              storage=[
                  type.filter(
                      value,
                      strict=strict,
                      allow_downcast=allow_downcast,
                  )
              ],
              readonly=False,
              strict=strict,
              allow_downcast=allow_downcast,
          )
  
      global __SHARED_CONTEXT__
  
      if isinstance(__SHARED_CONTEXT__, list):
          __SHARED_CONTEXT__.append(self)
  
      self._default_update: Optional[Variable] = None
  
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 1 to create a new SharedVariable object from inherited base classes: Variable with example: obj = SharedVariable(type, value, strict, allow_downcast, container, name)