class_docstr: Returns a callable that pads and stacks data.
  
  Parameters
  ----------
      axis (int, optional): The axis to pad the arrays.
          The arrays will be padded to the largest dimension at :attr:`axis`.
          For example, assume the input arrays have shape (10, 8, 5), (6, 8, 5), (3, 8, 5)
          and the `axis` is 0.
          Each input will be padded into (10, 8, 5) and then stacked to form the final output,
          which has shape（3, 10, 8, 5). (default ``0``)
      pad_val (float or int, optional): The padding value. (default ``0``)
      round_to (int, optional):
          If specified, the padded dimension will be rounded to be multiple of this argument.
          Mutually exclusive with :attr:`max_length`. (default ``None``)
      max_length (int, optional):
          If specified, the padded dimension will have length :attr:`max_length`,
          and it must be larger than the maximum length in the arrays at :attr:`axis`.
          Mutually exclusive with :attr:`round_to`.  (default ``None``)
      ret_length (bool, optional): Whether to return the valid length in the output.
          (default ``False``)
class_docstr_tok: ["Returns","a","callable","that","pads","and","stacks","data",".","Parameters","--","--","--","--","--","axis","(","int",",","optional",")",":","The","axis","to","pad","the","arrays",".","The","arrays","will","be","padded","to","the","largest","dimension","at",":","attr",":","`","axis","`",".","For","example",",","assume","the","input","arrays","have","shape","(","10",",","8",",","5",")",",","(","6",",","8",",","5",")",",","(","3",",","8",",","5",")","and","the","`","axis","`","is","0",".","Each","input","will","be","padded","into","(","10",",","8",",","5",")","and","then","stacked","to","form","the","final","output",",","which","has","shape\uff083",",","10",",","8",",","5",")",".","(","default","``","0","``",")","pad_val","(","float","or","int",",","optional",")",":","The","padding","value",".","(","default","``","0","``",")","round_to","(","int",",","optional",")",":","If","specified",",","the","padded","dimension","will","be","rounded","to","be","multiple","of","this","argument",".","Mutually","exclusive","with",":","attr",":","`","max_length","`",".","(","default","``","None","``",")","max_length","(","int",",","optional",")",":","If","specified",",","the","padded","dimension","will","have","length",":","attr",":","`","max_length","`",",","and","it","must","be","larger","than","the","maximum","length","in","the","arrays","at",":","attr",":","`","axis","`",".","Mutually","exclusive","with",":","attr",":","`","round_to","`",".","(","default","``","None","``",")","ret_length","(","bool",",","optional",")",":","Whether","to","return","the","valid","length","in","the","output",".","(","default","``","False","``",")"]
code: def __init__(
      self,
      axis=0,
      pad_val=0,
      round_to=None,
      max_length=None,
      ret_length=False,
  ):
      self._axis = axis
      if not isinstance(axis, int):
          raise ValueError(
              f"axis must be an integer! Received axis={axis}, type={type(axis)}."
          )
  
      if round_to is not None and max_length is not None:
          raise ValueError(
              f"Only either round_to={round_to} or max_length={max_length} can be specified."
          )
  
      self._pad_val = 0 if pad_val is None else pad_val
      self._round_to = round_to
      self._max_length = max_length
      self._ret_length = ret_length
  
      if pad_val is None:
          warnings.warn(
              "Padding value is not given and will be set automatically to 0 "
              "in data.Pad(). "
              "Please check whether this is intended "
              "(e.g. value of padding index in the tokenizer)."
          )
  
file_path: autogluon/multimodal/src/autogluon/multimodal/data/collator.py
imports: import math
  import warnings
  import numpy
  import torch
label_desc: Use image node_id 1 to create a new PadCollator object  with example: obj = PadCollator(axis, pad_val, round_to, max_length, ret_length)