code: def test_sample_invalid_weight_lengths(self, obj):
      # Weight length must be right
      msg = "Weights and axis to be sampled must be of same length"
      with pytest.raises(ValueError, match=msg):
          obj.sample(n=3, weights=[0, 1])
  
      with pytest.raises(ValueError, match=msg):
          obj.sample(n=3, weights=[0.5] * 11)
  
      with pytest.raises(
          ValueError, match="Fewer non-zero entries in p than size"
      ):
          obj.sample(n=4, weights=Series([0, 0, 0.2]))
  
imports: import numpy
  import pytest
  from pandas import DataFrame, Index, Series
  import pandas._testing
  import pandas.core.common
label_desc: Use image node_id 8 for calling the TestSample obj's underlying member method code with example usage: obj.test_sample_invalid_weight_lengths(obj) without return types