class_docstr: An encoder for text.
class_docstr_tok: ["An","encoder","for","text","."]
docstr: Encode all labels (inference mode & batched).
  
  :param labels:
      a sequence of strings to encode
  :param batch_size:
      the batch size to use for encoding the labels. ``batch_size=1``
      means that the labels are encoded one-by-one, while ``batch_size=len(labels)``
      would correspond to encoding all at once.
      Larger batch sizes increase memory requirements, but may be computationally
      more efficient. `batch_size` can also be set to `None` to enable automatic batch
      size maximization for the employed hardware.
  
  :returns: shape: (len(labels), dim)
      a tensor representing the encodings for all labels
docstr_tok: ["Encode","all","labels","(","inference","mode","&","batched",")",".",":","param","labels",":","a","sequence","of","strings","to","encode",":","param","batch_size",":","the","batch","size","to","use","for","encoding","the","labels",".","``","batch_size=1","``","means","that","the","labels","are","encoded","one-by-one",",","while","``","batch_size=len","(","labels",")","``","would","correspond","to","encoding","all","at","once",".","Larger","batch","sizes","increase","memory","requirements",",","but","may","be","computationally","more","efficient",".","`","batch_size","`","can","also","be","set","to","`","None","`","to","enable","automatic","batch","size","maximization","for","the","employed","hardware",".",":","returns",":","shape",":","(","len","(","labels",")",",","dim",")","a","tensor","representing","the","encodings","for","all","labels"]
code: def encode_all(
      self,
      labels: Sequence[str],
      batch_size: Optional[int] = None,
  ) -> torch.FloatTensor:
      """Encode all labels (inference mode & batched).
  
      :param labels:
          a sequence of strings to encode
      :param batch_size:
          the batch size to use for encoding the labels. ``batch_size=1``
          means that the labels are encoded one-by-one, while ``batch_size=len(labels)``
          would correspond to encoding all at once.
          Larger batch sizes increase memory requirements, but may be computationally
          more efficient. `batch_size` can also be set to `None` to enable automatic batch
          size maximization for the employed hardware.
  
      :returns: shape: (len(labels), dim)
          a tensor representing the encodings for all labels
      """
      return _encode_all_memory_utilization_optimized(
          encoder=self,
          labels=labels,
          batch_size=batch_size or len(labels),
      ).detach()
  
imports: import logging
  import string
  from abc import abstractmethod
  from typing import TYPE_CHECKING, Callable, Optional, Sequence, Union
  import torch
  from class_resolver import ClassResolver, Hint, HintOrType
  from class_resolver.contrib.torch import aggregation_resolver
  from more_itertools import chunked
  from torch import nn
  from torch_max_mem import maximize_memory_utilization
  from tqdm.auto import tqdm
  from ..utils import get_preferred_device, resolve_device, upgrade_to_sequence
label_desc: Use image node_id 3 for calling the TextEncoder obj's underlying member method code with example usage: obj.encode_all(labels, batch_size) and returns: _encode_all_memory_utilization_optimized