code: def _permute_tree(perm, tree):
      edges = [tuple(sorted([perm[u], perm[v]])) for (u, v) in tree]
      edges.sort(key=lambda uv: (uv[1], uv[0]))
      return tuple(edges)
  
imports: import itertools
  import math
  import torch
  from torch.distributions import constraints
  from torch.distributions.utils import lazy_property
  from pyro.distributions.torch_distribution import TorchDistribution
label_desc: Use image node_id 14 for calling a global function with example usage: _permute_tree(perm, tree) and returns: tuple