dimensions by using "refine_names()".
Basic name inference rules
Let's see how "match" and "unify" are used in name inference in the
case of adding two one-dim tensors with no broadcasting.
x = torch.randn(3, names=('X',))
   y = torch.randn(3)
   z = torch.randn(3, names=('Z',))
Check names: check that the names of the two tensors match.
For the following examples:



x + y  # match('X', None) is True
x + z  # match('X', 'Z') is False
x + x  # match('X', 'X') is True
x + z
   Error when attempting to broadcast dims ['X'] and dims ['Z']: dim 'X' and dim 'Z' are at the same position from the right but do not match.



Propagate names: unify the names to select which one to
propagate. In the case of "x + y", "unify('X', None) = 'X'" because
"'X'" is more specific than "None".



(x + y).names
   ('X',)
(x + x).names
   ('X',)



For a comprehensive list of name inference rules, see Named Tensors