class_docstr: Represents a sequence generator.
class_docstr_tok: ["Represents","a","sequence","generator","."]
docstr: Register a step hook on the sequence generator.
  
  The hook will be called after every generation step.
  
  :param hook:
      The hook to register.
  
  :returns:
      A handle that can be used to remove the added hook by calling
      ``handle.remove()``.
docstr_tok: ["Register","a","step","hook","on","the","sequence","generator",".","The","hook","will","be","called","after","every","generation","step",".",":","param","hook",":","The","hook","to","register",".",":","returns",":","A","handle","that","can","be","used","to","remove","the","added","hook","by","calling","``","handle.remove","(",")","``","."]
code: def register_step_hook(self, hook: StepHook) -> RemovableHandle:
      """Register a step hook on the sequence generator.
  
      The hook will be called after every generation step.
  
      :param hook:
          The hook to register.
  
      :returns:
          A handle that can be used to remove the added hook by calling
          ``handle.remove()``.
      """
      handle = RemovableHandle(self._step_hooks)
  
      self._step_hooks[handle.id] = hook
  
      return handle
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from collections import OrderedDict
  from dataclasses import dataclass
  from typing import Dict, List, Optional, Protocol
  from torch import Tensor
  from torch.utils.hooks import RemovableHandle
  from fairseq2.models.decoder import DecoderModel
  from fairseq2.models.encoder_decoder import EncoderDecoderModel
  from fairseq2.nn.padding import PaddingMask
label_desc: Use image node_id 3 for calling the SequenceGenerator obj's underlying member method code with example usage: obj.register_step_hook(hook) and returns: handle