code: def is_isomorphic(T1, T2):
      """
      Determine if two different cluster assignments are equivalent.
  
      Parameters
      ----------
      T1 : array_like
          An assignment of singleton cluster ids to flat cluster ids.
      T2 : array_like
          An assignment of singleton cluster ids to flat cluster ids.
  
      Returns
      -------
      b : bool
          Whether the flat cluster assignments `T1` and `T2` are
          equivalent.
  
      See Also
      --------
      linkage : for a description of what a linkage matrix is.
      fcluster : for the creation of flat cluster assignments.
  
      Examples
      --------
      >>> from scipy.cluster.hierarchy import fcluster, is_isomorphic
      >>> from scipy.cluster.hierarchy import single, complete
      >>> from scipy.spatial.distance import pdist
  
      Two flat cluster assignments can be isomorphic if they represent the same
      cluster assignment, with different labels.
  
      For example, we can use the `scipy.cluster.hierarchy.single`: method
      and flatten the output to four clusters:
  
      >>> X = [[0, 0], [0, 1], [1, 0],
      ...      [0, 4], [0, 3], [1, 4],
      ...      [4, 0], [3, 0], [4, 1],
      ...      [4, 4], [3, 4], [4, 3]]
  
      >>> Z = single(pdist(X))
      >>> T = fcluster(Z, 1, criterion='distance')
      >>> T
      array([3, 3, 3, 4, 4, 4, 2, 2, 2, 1, 1, 1], dtype=int32)
  
      We can then do the same using the
      `scipy.cluster.hierarchy.complete`: method:
  
      >>> Z = complete(pdist(X))
      >>> T_ = fcluster(Z, 1.5, criterion='distance')
      >>> T_
      array([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4], dtype=int32)
  
      As we can see, in both cases we obtain four clusters and all the data
      points are distributed in the same way - the only thing that changes
      are the flat cluster labels (3 => 1, 4 =>2, 2 =>3 and 4 =>1), so both
      cluster assignments are isomorphic:
  
      >>> is_isomorphic(T, T_)
      True
  
      """
      T1 = np.asarray(T1, order="c")
      T2 = np.asarray(T2, order="c")
  
      T1S = T1.shape
      T2S = T2.shape
  
      if len(T1S) != 1:
          raise ValueError("T1 must be one-dimensional.")
      if len(T2S) != 1:
          raise ValueError("T2 must be one-dimensional.")
      if T1S[0] != T2S[0]:
          raise ValueError(
              "T1 and T2 must have the same number of elements."
          )
      n = T1S[0]
      d1 = {}
      d2 = {}
      for i in range(0, n):
          if T1[i] in d1:
              if T2[i] not in d2:
                  return False
              if d1[T1[i]] != T2[i] or d2[T2[i]] != T1[i]:
                  return False
          elif T2[i] in d2:
              return False
          else:
              d1[T1[i]] = T2[i]
              d2[T2[i]] = T1[i]
      return True
  
imports: import warnings
  import bisect
  from collections import deque
  import numpy
  from .None import _hierarchy, _optimal_leaf_ordering
  import scipy.spatial.distance
  from scipy._lib._array_api import array_namespace, as_xparray, copy
  from scipy._lib._disjoint_set import DisjointSet
label_desc: Use image node_id 42 for calling a global function with example usage: is_isomorphic(T1, T2) and returns: True, False, False, False