code: def construct_scan(
      scan_args: ScanArgs, **kwargs
  ) -> Tuple[List[TensorVariable], OrderedUpdates]:
      scan_op = Scan(
          scan_args.inner_inputs,
          scan_args.inner_outputs,
          scan_args.info,
          **kwargs,
      )
      node = scan_op.make_node(*scan_args.outer_inputs)
      updates = OrderedUpdates(
          zip(scan_args.outer_in_shared, scan_args.outer_out_shared)
      )
      return node.outputs, updates
  
imports: from copy import copy
  from typing import Callable, Dict, Iterable, List, Optional, Tuple, cast
  import numpy
  import pytensor
  import pytensor.tensor
  from pytensor.graph.basic import Variable
  from pytensor.graph.op import compute_test_value
  from pytensor.graph.rewriting.basic import node_rewriter
  from pytensor.graph.rewriting.db import RewriteDatabaseQuery
  from pytensor.scan.op import Scan
  from pytensor.scan.rewriting import scan_eqopt1, scan_eqopt2
  from pytensor.scan.utils import ScanArgs
  from pytensor.tensor.random.type import RandomType
  from pytensor.tensor.subtensor import Subtensor, indices_from_subtensor
  from pytensor.tensor.variable import TensorVariable
  from pytensor.updates import OrderedUpdates
  from pymc.logprob.abstract import MeasurableVariable, _logprob
  from pymc.logprob.basic import conditional_logp
  from pymc.logprob.rewriting import PreserveRVMappings, construct_ir_fgraph, inc_subtensor_ops, logprob_rewrites_db, measurable_ir_rewrites_db
  from pymc.logprob.utils import replace_rvs_by_values
label_desc: Use image node_id 3 for calling a global function with example usage: construct_scan(scan_args) and returns: node,  updates