code: def shape_of_variables(fgraph, input_shapes):
      """
      Compute the numeric shape of all intermediate variables given input shapes.
  
      Parameters
      ----------
      fgraph
          The FunctionGraph in question.
      input_shapes : dict
          A dict mapping input to shape.
  
      Returns
      -------
      shapes : dict
          A dict mapping variable to shape
  
      .. warning:: This modifies the fgraph. Not pure.
  
      Examples
      --------
      >>> import pytensor
      >>> x = pytensor.tensor.matrix('x')
      >>> y = x[512:]; y.name = 'y'
      >>> fgraph = FunctionGraph([x], [y], clone=False)
      >>> d = shape_of_variables(fgraph, {x: (1024, 1024)})
      >>> d[y]
      (array(512), array(1024))
      >>> d[x]
      (array(1024), array(1024))
      """
  
      if not hasattr(fgraph, "shape_feature"):
          from pytensor.tensor.rewriting.shape import ShapeFeature
  
          fgraph.attach_feature(ShapeFeature())
  
      input_dims = [
          dimension
          for inp in fgraph.inputs
          for dimension in fgraph.shape_feature.shape_of[inp]
      ]
  
      output_dims = [
          dimension
          for shape in fgraph.shape_feature.shape_of.values()
          for dimension in shape
      ]
  
      compute_shapes = pytensor.function(input_dims, output_dims)
  
      if any(i not in fgraph.inputs for i in input_shapes.keys()):
          raise ValueError(
              "input_shapes keys aren't in the fgraph.inputs. FunctionGraph()"
              " interface changed. Now by default, it clones the graph it receives."
              " To have the old behavior, give it this new parameter `clone=False`."
          )
  
      numeric_input_dims = [
          dim for inp in fgraph.inputs for dim in input_shapes[inp]
      ]
      numeric_output_dims = compute_shapes(*numeric_input_dims)
  
      sym_to_num_dict = dict(zip(output_dims, numeric_output_dims))
  
      l = {}
      for var in fgraph.shape_feature.shape_of:
          l[var] = tuple(
              sym_to_num_dict[sym]
              for sym in fgraph.shape_feature.shape_of[var]
          )
      return l
  
file_path: pytensor/pytensor/tensor/utils.py
imports: import re
  from collections.abc import Sequence
  from typing import Union
  import numpy
  import pytensor
  from pytensor.utils import hash_from_code
label_desc: Use image node_id 2 for calling a global function with example usage: shape_of_variables(fgraph, input_shapes) and returns: l