code: def detect_encoding(texts, sample_size=32):
      if not isinstance(texts, list):
          # check for instance of list as bytes are supplied as input
          texts = [texts]
      lst = [
          chardet.detect(doc)["encoding"] for doc in texts[:sample_size]
      ]
      encoding = max(set(lst), key=lst.count)
      # standardize to utf-8 to prevent BERT problems
      encoding = (
          "utf-8"
          if encoding.lower() in ["ascii", "utf8", "utf-8"]
          else encoding
      )
      return encoding
  
imports: from subprocess import DEVNULL, PIPE, Popen
  from ..imports import *
label_desc: Use image node_id 18 for calling a global function with example usage: detect_encoding(texts, sample_size) and returns: encoding