class_docstr: Hidden Markov model class, a generative model for labelling sequence data.
  These models define the joint probability of a sequence of symbols and
  their labels (state transitions) as the product of the starting state
  probability, the probability of each state transition, and the probability
  of each observation being generated from each state. This is described in
  more detail in the module documentation.
  
  This implementation is based on the HMM description in Chapter 8, Huang,
  Acero and Hon, Spoken Language Processing and includes an extension for
  training shallow HMM parsers or specialized HMMs as in Molina et.
  al, 2002.  A specialized HMM modifies training data by applying a
  specialization function to create a new training set that is more
  appropriate for sequential tagging with an HMM.  A typical use case is
  chunking.
  
  :param symbols: the set of output symbols (alphabet)
  :type symbols: seq of any
  :param states: a set of states representing state space
  :type states: seq of any
  :param transitions: transition probabilities; Pr(s_i | s_j) is the
      probability of transition from state i given the model is in
      state_j
  :type transitions: ConditionalProbDistI
  :param outputs: output probabilities; Pr(o_k | s_i) is the probability
      of emitting symbol k when entering state i
  :type outputs: ConditionalProbDistI
  :param priors: initial state distribution; Pr(s_i) is the probability
      of starting in state i
  :type priors: ProbDistI
  :param transform: an optional function for transforming training
      instances, defaults to the identity function.
  :type transform: callable
docstr: Train a new HiddenMarkovModelTagger using the given labeled and
  unlabeled training instances. Testing will be performed if test
  instances are provided.
  
  :return: a hidden markov model tagger
  :rtype: HiddenMarkovModelTagger
  :param labeled_sequence: a sequence of labeled training instances,
      i.e. a list of sentences represented as tuples
  :type labeled_sequence: list(list)
  :param test_sequence: a sequence of labeled test instances
  :type test_sequence: list(list)
  :param unlabeled_sequence: a sequence of unlabeled training instances,
      i.e. a list of sentences represented as words
  :type unlabeled_sequence: list(list)
  :param transform: an optional function for transforming training
      instances, defaults to the identity function, see ``transform()``
  :type transform: function
  :param estimator: an optional function or class that maps a
      condition's frequency distribution to its probability
      distribution, defaults to a Lidstone distribution with gamma = 0.1
  :type estimator: class or function
  :param verbose: boolean flag indicating whether training should be
      verbose or include printed output
  :type verbose: bool
  :param max_iterations: number of Baum-Welch iterations to perform
  :type max_iterations: int
docstr_tok: ["Train","a","new","HiddenMarkovModelTagger","using","the","given","labeled","and","unlabeled","training","instances",".","Testing","will","be","performed","if","test","instances","are","provided",".",":","return",":","a","hidden","markov","model","tagger",":","rtype",":","HiddenMarkovModelTagger",":","param","labeled_sequence",":","a","sequence","of","labeled","training","instances",",","i.e",".","a","list","of","sentences","represented","as","tuples",":","type","labeled_sequence",":","list","(","list",")",":","param","test_sequence",":","a","sequence","of","labeled","test","instances",":","type","test_sequence",":","list","(","list",")",":","param","unlabeled_sequence",":","a","sequence","of","unlabeled","training","instances",",","i.e",".","a","list","of","sentences","represented","as","words",":","type","unlabeled_sequence",":","list","(","list",")",":","param","transform",":","an","optional","function","for","transforming","training","instances",",","defaults","to","the","identity","function",",","see","``","transform","(",")","``",":","type","transform",":","function",":","param","estimator",":","an","optional","function","or","class","that","maps","a","condition","'s","frequency","distribution","to","its","probability","distribution",",","defaults","to","a","Lidstone","distribution","with","gamma","=","0.1",":","type","estimator",":","class","or","function",":","param","verbose",":","boolean","flag","indicating","whether","training","should","be","verbose","or","include","printed","output",":","type","verbose",":","bool",":","param","max_iterations",":","number","of","Baum-Welch","iterations","to","perform",":","type","max_iterations",":","int"]
code: def train(
      cls,
      labeled_sequence,
      test_sequence=None,
      unlabeled_sequence=None,
      **kwargs,
  ):
      """
      Train a new HiddenMarkovModelTagger using the given labeled and
      unlabeled training instances. Testing will be performed if test
      instances are provided.
  
      :return: a hidden markov model tagger
      :rtype: HiddenMarkovModelTagger
      :param labeled_sequence: a sequence of labeled training instances,
          i.e. a list of sentences represented as tuples
      :type labeled_sequence: list(list)
      :param test_sequence: a sequence of labeled test instances
      :type test_sequence: list(list)
      :param unlabeled_sequence: a sequence of unlabeled training instances,
          i.e. a list of sentences represented as words
      :type unlabeled_sequence: list(list)
      :param transform: an optional function for transforming training
          instances, defaults to the identity function, see ``transform()``
      :type transform: function
      :param estimator: an optional function or class that maps a
          condition's frequency distribution to its probability
          distribution, defaults to a Lidstone distribution with gamma = 0.1
      :type estimator: class or function
      :param verbose: boolean flag indicating whether training should be
          verbose or include printed output
      :type verbose: bool
      :param max_iterations: number of Baum-Welch iterations to perform
      :type max_iterations: int
      """
      return cls._train(
          labeled_sequence, test_sequence, unlabeled_sequence, **kwargs
      )
  
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 3 for calling the HiddenMarkovModelTagger obj's underlying member method code with example usage: obj.train(cls, labeled_sequence, test_sequence, unlabeled_sequence) and returns: cls