code: def coverage_ratio(x: Bin, y: Bin) -> float:
      """Returns the amount of y covered by x.
  
      Examples
      --------
  
      >>> coverage_ratio(Bin(1, 2, 0), Bin(1, 2, 0))
      1.0
  
      >>> coverage_ratio(Bin(1, 3, 0), Bin(2, 4, 0))
      0.5
  
      >>> coverage_ratio(Bin(1, 3, 0), Bin(3, 5, 0))
      0.0
  
      >>> coverage_ratio(Bin(1, 3, 0), Bin(0, 4, 0))
      0.5
  
      >>> coverage_ratio(Bin(0, 4, 0), Bin(1, 3, 0))
      1.0
  
      >>> coverage_ratio(Bin(1, 3, 0), Bin(0, 1, 0))
      0.0
  
      >>> coverage_ratio(Bin(1, 1, 0), Bin(1, 1, 0))
      1.0
  
      """
      if y.left == y.right:
          return float(x.left <= y.left <= x.right)
      return max(0, min(x.right, y.right) - max(x.left, y.left)) / (
          y.right - y.left
      )
  
imports: from __future__ import annotations
  import collections
  import heapq
  import itertools
  import math
  from river import base
label_desc: Use image node_id 1 for calling a global function with example usage: coverage_ratio(x, y) and returns: unknown, float