code: def test_params_p_sampling(self):
      beam_search = BeamSearch.from_params(
          Params(
              {
                  "sampler": {
                      "type": "top-p",
                      "p": 0.8,
                  },
                  "beam_size": 2,
                  "end_index": 7,
              }
          )
      )
      assert beam_search.beam_size == 2
      assert beam_search._end_index == 7
      assert beam_search.sampler is not None
  
imports: from typing import Dict, Tuple, Union
  import numpy
  import pytest
  import torch
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.nn.beam_search import MultinomialSampler, BeamSearch, TopKSampler, TopPSampler, GumbelSampler, LengthNormalizedSequenceLogProbabilityScorer, RepeatedNGramBlockingConstraint, StepFunctionTypeWithTimestep, StepFunctionTypeNoTimestep
  from allennlp.common.params import Params
  from allennlp.nn.util import min_value_of_dtype
label_desc: Use image node_id 23 for calling the BeamSearchTest obj's underlying member method code with example usage: obj.test_params_p_sampling() without return types