code: def bag(seq1: Iterable[str], seq2: Iterable[str]) -> float:
      """
      Measure the similarity between two sequences of strings (*not* as sets)
      using the "bag distance" measure, which can be considered an approximation
      of edit distance.
  
      Args:
          seq1
          seq2
  
      Returns:
          Similarity between ``seq1`` and ``seq2`` in the interval [0.0, 1.0],
          where larger values correspond to more similar sequences
  
      Reference:
          Bartolini, Ilaria, Paolo Ciaccia, and Marco Patella. "String matching with
          metric trees using an approximate distance." International Symposium on String
          Processing and Information Retrieval. Springer, Berlin, Heidelberg, 2002.
      """
      bag1 = collections.Counter(seq1)
      bag2 = collections.Counter(seq2)
      max_diff = max(
          sum((bag1 - bag2).values()), sum((bag2 - bag1).values())
      )
      max_len = max(sum(bag1.values()), sum(bag2.values()))
      try:
          return 1.0 - (max_diff / max_len)
      except ZeroDivisionError:
          return 0.0
  
imports: import collections
  import math
  from typing import Iterable
label_desc: Use image node_id 5 for calling a global function with example usage: bag(seq1, seq2) and returns: unknown, int