code: def local_subtensor_of_alloc(fgraph, node):
      """
  
      alloc(val)[x:y] -> alloc(val[...])
      alloc(val)[x:y] -> alloc(val)
      This can be seen as a lift, but it also reduce the number of computation/memory.
  
      """
      if not isinstance(node.op, Subtensor):
          return False
      u = node.inputs[0]
      if u.owner is None:
          return False
      if not isinstance(u.owner.op, Alloc):
          return False
      slices = get_idx_list(node.inputs, node.op.idx_list)
      val = u.owner.inputs[0]
      dims = u.owner.inputs[1:]
      assert len(slices) <= len(dims)
  
      # Number of dimensions added to val
      n_added_dims = u.ndim - val.ndim
      # Dimensions of the returned alloc
      nw_dims = []
      # Slices to take from val
      val_slices = []
  
      for i, (sl, dim) in enumerate(zip(slices, dims)):
          # If val was not copied over that dim,
          # we need to take the appropriate subtensor on it.
          if i >= n_added_dims:
              # We check that the corresponding val dimensions was
              # not a broadcasted dimensions.
              if (
                  val.type.ndim > (i - n_added_dims)
                  and val.type.broadcastable[i - n_added_dims]
              ):
                  val_slices.append(slice(None))
              else:
                  val_slices.append(sl)
  
          csl, _ = get_canonical_form_slice(sl, dim)
          if type(csl) is not slice:
              # That dimension is removed.
              pass
          else:
              nw_dim = csl.stop - csl.start
  
              if csl.step != 1:
                  # Do not add the ceil_intdiv() graphs in the graphs
                  # when this is not needed as it prevent detecting the
                  # correct broadcast pattern.
                  nw_dim = ceil_intdiv(nw_dim, csl.step)
              nw_dims += [nw_dim]
  
      nw_val = val[tuple(val_slices)]
      nw_dims += dims[len(slices) :]
      if nw_val.ndim > len(nw_dims):
          return False
      rval = alloc(nw_val, *nw_dims)
      if not isinstance(rval, (list, tuple)):
          rval = [rval]
      return rval
  
imports: import sys
  from collections.abc import Iterable
  import numpy
  import pytensor
  import pytensor.scalar.basic
  from pytensor import compile
  from pytensor.graph.basic import Constant, Variable
  from pytensor.graph.rewriting.basic import WalkingGraphRewriter, copy_stack_trace, in2out, node_rewriter
  from pytensor.raise_op import Assert
  from pytensor.tensor.basic import Alloc, Join, MakeVector, ScalarFromTensor, TensorFromScalar, alloc, as_tensor, cast, concatenate, extract_constant, get_underlying_scalar_constant_value, register_infer_shape, switch
  from pytensor.tensor.blockwise import Blockwise
  from pytensor.tensor.elemwise import Elemwise
  from pytensor.tensor.exceptions import NotScalarConstantError
  from pytensor.tensor.math import Dot, add, and_, ceil_intdiv, dot, eq, ge, gt, le, lt, maximum, minimum, or_
  from pytensor.tensor.math import all
  from pytensor.tensor.rewriting.basic import register_canonicalize, register_specialize, register_stabilize
  from pytensor.tensor.shape import Shape, SpecifyShape, Unbroadcast, shape_padleft, shape_tuple, specify_shape, unbroadcast
  from pytensor.tensor.sharedvar import TensorSharedVariable
  from pytensor.tensor.subtensor import AdvancedIncSubtensor, AdvancedIncSubtensor1, AdvancedSubtensor, AdvancedSubtensor1, IncSubtensor, Subtensor, advanced_inc_subtensor1, advanced_subtensor, advanced_subtensor1, as_index_constant, as_index_literal, get_canonical_form_slice, get_constant_idx, get_idx_list, get_slice_elements, inc_subtensor, indices_from_subtensor
  from pytensor.tensor.type import TensorType
  from pytensor.tensor.type_other import NoneTypeT, SliceConstant, SliceType
  from pytensor.tensor.variable import TensorConstant, TensorVariable
label_desc: Use image node_id 12 for calling a global function with example usage: local_subtensor_of_alloc(fgraph, node) and returns: rval, False, False, False, False