def assertEachInputRankAndCompatibilityChecked(self, nt, inputs,
                                                 invalid_inputs, nt_name):
    """Check class constructor raises exception if an input tensor is invalid.

    Args:
      nt: namedtuple to be tested.
      inputs: list of (valid) inputs to class constructor.
      invalid_inputs: list of invalid alternative inputs. Should be of same
        length as `inputs`, so that each input can be swapped out for a broken
        input individually.
      nt_name: A string specifying the name of the namedtuple.
    """
    for i, alt_input in enumerate(invalid_inputs):
      broken_inputs = list(inputs)
      broken_inputs[i] = alt_input
      with self.assertRaisesRegexp(
          ValueError,
          "{}: Error in rank and/or compatibility check".format(nt_name)):
        nt(*broken_inputs)
Check class constructor raises exception if an input tensor is invalid.

    Args:
      nt: namedtuple to be tested.
      inputs: list of (valid) inputs to class constructor.
      invalid_inputs: list of invalid alternative inputs. Should be of same
        length as `inputs`, so that each input can be swapped out for a broken
        input individually.
      nt_name: A string specifying the name of the namedtuple.
    
trfl/dist_value_ops_test.py