class_docstr: Algorithms for learning HMM parameters from training data. These include
  both supervised learning (MLE) and unsupervised learning (Baum-Welch).
  
  Creates an HMM trainer to induce an HMM with the given states and
  output symbol alphabet. A supervised and unsupervised training
  method may be used. If either of the states or symbols are not given,
  these may be derived from supervised training.
  
  :param states:  the set of state labels
  :type states:   sequence of any
  :param symbols: the set of observation symbols
  :type symbols:  sequence of any
docstr: Supervised training maximising the joint probability of the symbol and
  state sequences. This is done via collecting frequencies of
  transitions between states, symbol observations while within each
  state and which states start a sentence. These frequency distributions
  are then normalised into probability estimates, which can be
  smoothed if desired.
  
  :return: the trained model
  :rtype: HiddenMarkovModelTagger
  :param labelled_sequences: the training data, a set of
      labelled sequences of observations
  :type labelled_sequences: list
  :param estimator: a function taking
      a FreqDist and a number of bins and returning a CProbDistI;
      otherwise a MLE estimate is used
docstr_tok: ["Supervised","training","maximising","the","joint","probability","of","the","symbol","and","state","sequences",".","This","is","done","via","collecting","frequencies","of","transitions","between","states",",","symbol","observations","while","within","each","state","and","which","states","start","a","sentence",".","These","frequency","distributions","are","then","normalised","into","probability","estimates",",","which","can","be","smoothed","if","desired",".",":","return",":","the","trained","model",":","rtype",":","HiddenMarkovModelTagger",":","param","labelled_sequences",":","the","training","data",",","a","set","of","labelled","sequences","of","observations",":","type","labelled_sequences",":","list",":","param","estimator",":","a","function","taking","a","FreqDist","and","a","number","of","bins","and","returning","a","CProbDistI",";","otherwise","a","MLE","estimate","is","used"]
code: def train_supervised(self, labelled_sequences, estimator=None):
      """
      Supervised training maximising the joint probability of the symbol and
      state sequences. This is done via collecting frequencies of
      transitions between states, symbol observations while within each
      state and which states start a sentence. These frequency distributions
      are then normalised into probability estimates, which can be
      smoothed if desired.
  
      :return: the trained model
      :rtype: HiddenMarkovModelTagger
      :param labelled_sequences: the training data, a set of
          labelled sequences of observations
      :type labelled_sequences: list
      :param estimator: a function taking
          a FreqDist and a number of bins and returning a CProbDistI;
          otherwise a MLE estimate is used
      """
  
      # default to the MLE estimate
      if estimator is None:
          estimator = lambda fdist, bins: MLEProbDist(fdist)
  
      # count occurrences of starting states, transitions out of each state
      # and output symbols observed in each state
      known_symbols = set(self._symbols)
      known_states = set(self._states)
  
      starting = FreqDist()
      transitions = ConditionalFreqDist()
      outputs = ConditionalFreqDist()
      for sequence in labelled_sequences:
          lasts = None
          for token in sequence:
              state = token[_TAG]
              symbol = token[_TEXT]
              if lasts is None:
                  starting[state] += 1
              else:
                  transitions[lasts][state] += 1
              outputs[state][symbol] += 1
              lasts = state
  
              # update the state and symbol lists
              if state not in known_states:
                  self._states.append(state)
                  known_states.add(state)
  
              if symbol not in known_symbols:
                  self._symbols.append(symbol)
                  known_symbols.add(symbol)
  
      # create probability distributions (with smoothing)
      N = len(self._states)
      pi = estimator(starting, N)
      A = ConditionalProbDist(transitions, estimator, N)
      B = ConditionalProbDist(outputs, estimator, len(self._symbols))
  
      return HiddenMarkovModelTagger(
          self._symbols, self._states, A, B, pi
      )
  
imports: import itertools
  import re
  from nltk.metrics import accuracy
  from nltk.probability import ConditionalFreqDist, ConditionalProbDist, DictionaryConditionalProbDist, DictionaryProbDist, FreqDist, LidstoneProbDist, MLEProbDist, MutableProbDist, RandomProbDist
  from nltk.tag.api import TaggerI
  from nltk.util import LazyMap, unique_list
label_desc: Use image node_id 5 for calling the HiddenMarkovModelTrainer obj's underlying member method code with example usage: obj.train_supervised(labelled_sequences, estimator) and returns: HiddenMarkovModelTagger