code: def get_token_count(x, tokenizer):
      # NOTE: Somewhat duplicates get_token_count()
      # handle ambiguity in if get dict or list
      if hasattr(tokenizer, "encode"):
          tokens = tokenizer.encode(x)
      else:
          tokens = tokenizer(x)
      if isinstance(tokens, dict) and "input_ids" in tokens:
          tokens = tokens["input_ids"]
      if isinstance(tokens, list):
          n_tokens = len(tokens)
      elif len(tokens.shape) == 2:
          n_tokens = tokens.shape[1]
      elif len(tokens.shape) == 1:
          n_tokens = tokens.shape[0]
      else:
          raise RuntimeError("Cannot handle tokens: %s" % tokens)
      return n_tokens
  
file_path: h2ogpt/src/h2oai_pipeline.py
imports: import os
  from transformers import TextGenerationPipeline
  from transformers.pipelines.text_generation import ReturnType
  from stopping import get_stopping
  from prompter import Prompter
label_desc: Use image node_id 2 for calling the H2OTextGenerationPipeline obj's underlying member method code with example usage: obj.get_token_count(x, tokenizer) and returns: n_tokens