code: def filtering(self, logits, seed):
      top_k = seed["top_k"]
      top_p = seed["top_p"]
  
      check_top_k = False
      check_top_p = False
  
      if top_k is not None and 0 < top_k < len(logits):
          logits, idxes = filtering.filter_top_k(
              logits, top_k, replace=-float("Inf")
          )
          check_top_k = True
      if top_p is not None and 0 < top_p < 1:
          logits, idxes = filtering.nucleus_sampling(logits, top_p)
          check_top_p = True
  
      # If top_p is not None, value will be sorted, so no need to select it again
      if not check_top_p:
          if check_top_k:
              logits = logits.index_select(0, idxes)
              # TODO: Externalize to util for checking
              if "cuda" in self.device:
                  idxes = idxes.cpu()
              idxes = idxes.detach().numpy().tolist()
          else:
              idxes = np.arange(len(logits)).tolist()
      else:
          logits = logits[: len(idxes)]
          # TODO: Externalize to util for checking
          if "cuda" in self.device:
              idxes = idxes.cpu()
          idxes = idxes.detach().numpy().tolist()
  
      return logits, idxes
  
imports: import numpy
  import string
  import nlpaug.util.selection.filtering
label_desc: Use image node_id 18 for calling the LanguageModels obj's underlying member method code with example usage: obj.filtering(logits, seed) and returns: logits,  idxes