docstr: Sorts a tuple, optionally removing duplicates.
  
  Parameters
  ----------
  x:
      Tuple to be sorted.
  allow_duplicates:
      If ``True``, duplicate entries are kept.
  
  Returns
  -------
  A sorted tuple.
docstr_tok: ["Sorts","a","tuple",",","optionally","removing","duplicates",".","Parameters","--","--","--","--","--","x",":","Tuple","to","be","sorted",".","allow_duplicates",":","If","``","True","``",",","duplicate","entries","are","kept",".","Returns","--","--","--","-","A","sorted","tuple","."]
code: def _sort(x: tuple, allow_duplicates=False) -> tuple:
      """
      Sorts a tuple, optionally removing duplicates.
  
      Parameters
      ----------
      x:
          Tuple to be sorted.
      allow_duplicates:
          If ``True``, duplicate entries are kept.
  
      Returns
      -------
      A sorted tuple.
      """
  
      if allow_duplicates:
          return tuple(sorted(x))
  
      return tuple(sorted(set(x)))
  
imports: import copy
  import logging
  from collections import defaultdict, namedtuple
  from typing import Callable, Dict, List, Optional, Set, Tuple
  import numpy
  from alibi.utils.distributions import kl_bernoulli
label_desc: Use image node_id 3 for calling the AnchorBaseBeam obj's underlying member method code with example usage: obj._sort(x, allow_duplicates) and returns: tuple, tuple