class_docstr: A class that models and constructs operations in a graph.
  
  A `Op` instance has several responsibilities:
  
  * construct `Apply` nodes via :meth:`Op.make_node` method,
  * perform the numeric calculation of the modeled operation via the
    :meth:`Op.perform` method,
  * and (optionally) build the gradient-calculating sub-graphs via the
    :meth:`Op.grad` method.
  
  To see how `Op`, `Type`, `Variable`, and `Apply` fit together see the
  page on :doc:`graph`.
  
  For more details regarding how these methods should behave: see the `Op
  Contract` in the sphinx docs (advanced tutorial on `Op` making).
class_docstr_tok: ["A","class","that","models","and","constructs","operations","in","a","graph",".","A","`","Op","`","instance","has","several","responsibilities",":","*","construct","`","Apply","`","nodes","via",":","meth",":","`","Op.make_node","`","method",",","*","perform","the","numeric","calculation","of","the","modeled","operation","via","the",":","meth",":","`","Op.perform","`","method",",","*","and","(","optionally",")","build","the","gradient-calculating","sub-graphs","via","the",":","meth",":","`","Op.grad","`","method",".","To","see","how","`","Op","`",",","`","Type","`",",","`","Variable","`",",","and","`","Apply","`","fit","together","see","the","page","on",":","doc",":","`","graph","`",".","For","more","details","regarding","how","these","methods","should","behave",":","see","the","`","Op","Contract","`","in","the","sphinx","docs","(","advanced","tutorial","on","`","Op","`","making",")","."]
docstr: Construct an `Apply` node using :meth:`Op.make_node` and return its outputs.
  
  This method is just a wrapper around :meth:`Op.make_node`.
  
  It is called by code such as:
  
  .. code-block:: python
  
     x = pytensor.tensor.matrix()
     y = pytensor.tensor.exp(x)
  
  
  `pytensor.tensor.exp` is an `Op` instance, so ``pytensor.tensor.exp(x)`` calls
  :meth:`pytensor.tensor.exp.__call__` (i.e. this method) and returns its single output
  `Variable`, ``y``.  The `Apply` node constructed by :meth:`self.make_node`
  behind the scenes is available via ``y.owner``.
  
  `Op` authors are able to determine which output is returned by this method
  via the :attr:`Op.default_output` property.
  
  Parameters
  ----------
  inputs : tuple of Variable
      The `Op`'s inputs.
  kwargs
      Additional keyword arguments to be forwarded to
      :meth:`Op.make_node` *except* for optional argument ``return_list`` (which
      defaults to ``False``). If ``return_list`` is ``True``, then the returned
      value is always a ``list``. Otherwise it is either a single `Variable`
      when the output of :meth:`Op.make_node` contains a single element, or this
      output (unchanged) when it contains multiple elements.
  
  Returns
  -------
  outputs : list of Variable or Variable
      Either a list of output `Variable`\s, or a single `Variable`.
      This is determined by the number of outputs produced by the
      `Op`, the value of the keyword ``return_list``, and the value of
      the :attr:`Op.default_output` property.
docstr_tok: ["Construct","an","`","Apply","`","node","using",":","meth",":","`","Op.make_node","`","and","return","its","outputs",".","This","method","is","just","a","wrapper","around",":","meth",":","`","Op.make_node","`",".","It","is","called","by","code","such","as",":","..","code-block",":",":","python","x","=","pytensor.tensor.matrix","(",")","y","=","pytensor.tensor.exp","(","x",")","`","pytensor.tensor.exp","`","is","an","`","Op","`","instance",",","so","``","pytensor.tensor.exp","(","x",")","``","calls",":","meth",":","`","pytensor.tensor.exp.__call__","`","(","i.e",".","this","method",")","and","returns","its","single","output","`","Variable","`",",","``","y","``",".","The","`","Apply","`","node","constructed","by",":","meth",":","`","self.make_node","`","behind","the","scenes","is","available","via","``","y.owner","``",".","`","Op","`","authors","are","able","to","determine","which","output","is","returned","by","this","method","via","the",":","attr",":","`","Op.default_output","`","property",".","Parameters","--","--","--","--","--","inputs",":","tuple","of","Variable","The","`","Op","`","'s","inputs",".","kwargs","Additional","keyword","arguments","to","be","forwarded","to",":","meth",":","`","Op.make_node","`","*","except","*","for","optional","argument","``","return_list","``","(","which","defaults","to","``","False","``",")",".","If","``","return_list","``","is","``","True","``",",","then","the","returned","value","is","always","a","``","list","``",".","Otherwise","it","is","either","a","single","`","Variable","`","when","the","output","of",":","meth",":","`","Op.make_node","`","contains","a","single","element",",","or","this","output","(","unchanged",")","when","it","contains","multiple","elements",".","Returns","--","--","--","-","outputs",":","list","of","Variable","or","Variable","Either","a","list","of","output","`","Variable","`","\\s",",","or","a","single","`","Variable","`",".","This","is","determined","by","the","number","of","outputs","produced","by","the","`","Op","`",",","the","value","of","the","keyword","``","return_list","``",",","and","the","value","of","the",":","attr",":","`","Op.default_output","`","property","."]
code: def __call__(
      self, *inputs: Any, **kwargs
  ) -> Union[Variable, list[Variable]]:
      r"""Construct an `Apply` node using :meth:`Op.make_node` and return its outputs.
  
      This method is just a wrapper around :meth:`Op.make_node`.
  
      It is called by code such as:
  
      .. code-block:: python
  
         x = pytensor.tensor.matrix()
         y = pytensor.tensor.exp(x)
  
  
      `pytensor.tensor.exp` is an `Op` instance, so ``pytensor.tensor.exp(x)`` calls
      :meth:`pytensor.tensor.exp.__call__` (i.e. this method) and returns its single output
      `Variable`, ``y``.  The `Apply` node constructed by :meth:`self.make_node`
      behind the scenes is available via ``y.owner``.
  
      `Op` authors are able to determine which output is returned by this method
      via the :attr:`Op.default_output` property.
  
      Parameters
      ----------
      inputs : tuple of Variable
          The `Op`'s inputs.
      kwargs
          Additional keyword arguments to be forwarded to
          :meth:`Op.make_node` *except* for optional argument ``return_list`` (which
          defaults to ``False``). If ``return_list`` is ``True``, then the returned
          value is always a ``list``. Otherwise it is either a single `Variable`
          when the output of :meth:`Op.make_node` contains a single element, or this
          output (unchanged) when it contains multiple elements.
  
      Returns
      -------
      outputs : list of Variable or Variable
          Either a list of output `Variable`\s, or a single `Variable`.
          This is determined by the number of outputs produced by the
          `Op`, the value of the keyword ``return_list``, and the value of
          the :attr:`Op.default_output` property.
  
      """
      return_list = kwargs.pop("return_list", False)
      node = self.make_node(*inputs, **kwargs)
  
      if config.compute_test_value != "off":
          compute_test_value(node)
  
      if self.default_output is not None:
          rval = node.outputs[self.default_output]
          if return_list:
              return [rval]
          return rval
      else:
          if return_list:
              return list(node.outputs)
          elif len(node.outputs) == 1:
              return node.outputs[0]
          else:
              return node.outputs
  
imports: import copy
  import sys
  import warnings
  from abc import ABC, abstractmethod
  from collections.abc import Sequence
  from typing import TYPE_CHECKING, Any, Callable, Optional, Protocol, TypeVar, Union, cast
  import pytensor
  from pytensor.configdefaults import config
  from pytensor.graph.basic import Apply, Variable
  from pytensor.graph.utils import MetaObject, TestValueError, add_tag_trace, get_variable_trace_string
label_desc: Use image node_id 2 for calling the Op obj's underlying member method code with example usage: obj.__call__() and returns: rval, list, list, node, node