code: def analyze_stack(op: parser.InstDef) -> StackEffect:
      inputs: list[StackItem] = [
          convert_stack_item(i)
          for i in op.inputs
          if isinstance(i, parser.StackEffect)
      ]
      outputs: list[StackItem] = [
          convert_stack_item(i) for i in op.outputs
      ]
      for input, output in zip(inputs, outputs):
          if input.name == output.name:
              input.peek = output.peek = True
      return StackEffect(inputs, outputs)
  
imports: from dataclasses import dataclass, field
  import lexer
  import parser
  from typing import Optional
label_desc: Use image node_id 4 for calling a global function with example usage: analyze_stack(op) and returns: StackEffect