class_docstr: Class implementing OneHotEncoder operators for strings in PyTorch.
  
  Because we are dealing with tensors, strings require additional length information for processing.
code: def __init__(
      self, logical_operator, categories, device, extra_config={}
  ):
      super(OneHotEncoderString, self).__init__(
          logical_operator, transformer=True
      )
  
      self.num_columns = len(categories)
      self.max_word_length = max(
          [max([len(c) for c in cat]) for cat in categories]
      )
  
      # Strings are casted to int32, therefore we need to properly size the tensor to me dividable by 4.
      while self.max_word_length % 4 != 0:
          self.max_word_length += 1
  
      max_length = 0
      if constants.MAX_STRING_LENGTH in extra_config:
          max_length = extra_config[constants.MAX_STRING_LENGTH]
      extra_config[constants.MAX_STRING_LENGTH] = max(
          max_length, self.max_word_length
      )
  
      # We build condition tensors as a 2d tensor of integers.
      # The first dimension is of size num words, the second dimension is fixed to the max word length (// 4).
      condition_tensors = []
      categories_idx = [0]
      for arr in categories:
          cats = (
              np.array(
                  arr, dtype="|S" + str(self.max_word_length)
              )  # Encode objects into 4 byte strings.
              .view("int32")
              .reshape(-1, self.max_word_length // 4)
              .tolist()
          )
          # We merge all categories for all columns into a single tensor
          condition_tensors.extend(cats)
          # Since all categories are merged together, we need to track of indexes to retrieve them at inference time.
          categories_idx.append(categories_idx[-1] + len(cats))
      self.condition_tensors = torch.nn.Parameter(
          torch.IntTensor(condition_tensors), requires_grad=False
      )
      self.categories_idx = categories_idx
  
file_path: hummingbird/hummingbird/ml/operator_converters/_one_hot_encoder_implementations.py
imports: import numpy
  import torch
  from ._physical_operator import PhysicalOperator
  from .None import constants
label_desc: Use image node_id 1 to create a new OneHotEncoderString object from inherited base classes: PhysicalOperator, torch.nn with example: obj = OneHotEncoderString(logical_operator, categories, device, extra_config)