parameters: (rhs, input_labels, n_bcast_dims)
docstring: Check whether the equation's right hand side is valid
docstring_summary: Check whether the equation's right hand side is valid
docstring_tokens: Check whether the equation s right hand side is valid
function: def validate_rhs(rhs, input_labels, n_bcast_dims):
      '''
      Check whether the equation's right hand side is valid 
      '''
      # Sanity check.
      if n_bcast_dims > 0:
          assert '...' in rhs, (
              f"Invalid equation: missing ellipsis in output labels.")
  
      rhs = rhs.replace('...', '')
      rhs_set = set(rhs)
  
      # Hidden assumption: availble labels don't include '.'
      assert '.' not in input_labels
  
      # Verify that output labels all come from the set of input labels
      non_input_labels = rhs_set.difference(input_labels)
      assert not non_input_labels, (
          f"Invalid equation: "
          f"output label {sorted(non_input_labels)} not used by any input.")
      # Verify that output labels are not duplicate
      assert len(rhs) == len(rhs_set), (
          f"Invalid equation: duplicate output labels are found.")
function_tokens: def validate_rhs ( rhs , input_labels , n_bcast_dims ) : # Sanity check. if n_bcast_dims > 0 : assert '...' in rhs , ( f"Invalid equation: missing ellipsis in output labels." ) rhs = rhs . replace ( '...' , '' ) rhs_set = set ( rhs ) # Hidden assumption: availble labels don't include '.' assert '.' not in input_labels # Verify that output labels all come from the set of input labels non_input_labels = rhs_set . difference ( input_labels ) assert not non_input_labels , ( f"Invalid equation: " f"output label {sorted(non_input_labels)} not used by any input." ) # Verify that output labels are not duplicate assert len ( rhs ) == len ( rhs_set ) , ( f"Invalid equation: duplicate output labels are found." )