class_docstr: A batch of Instances. In addition to containing the instances themselves,
  it contains helper functions for converting the data into tensors.
  
  A Batch just takes an iterable of instances in its constructor and hangs onto them
  in a list.
class_docstr_tok: ["A","batch","of","Instances",".","In","addition","to","containing","the","instances","themselves",",","it","contains","helper","functions","for","converting","the","data","into","tensors",".","A","Batch","just","takes","an","iterable","of","instances","in","its","constructor","and","hangs","onto","them","in","a","list","."]
docstr: Gets the maximum padding lengths from all `Instances` in this batch.  Each `Instance`
  has multiple `Fields`, and each `Field` could have multiple things that need padding.
  We look at all fields in all instances, and find the max values for each (field_name,
  padding_key) pair, returning them in a dictionary.
  
  This can then be used to convert this batch into arrays of consistent length, or to set
  model parameters, etc.
docstr_tok: ["Gets","the","maximum","padding","lengths","from","all","`","Instances","`","in","this","batch",".","Each","`","Instance","`","has","multiple","`","Fields","`",",","and","each","`","Field","`","could","have","multiple","things","that","need","padding",".","We","look","at","all","fields","in","all","instances",",","and","find","the","max","values","for","each","(","field_name",",","padding_key",")","pair",",","returning","them","in","a","dictionary",".","This","can","then","be","used","to","convert","this","batch","into","arrays","of","consistent","length",",","or","to","set","model","parameters",",","etc","."]
code: def get_padding_lengths(self) -> Dict[str, Dict[str, int]]:
      """
      Gets the maximum padding lengths from all `Instances` in this batch.  Each `Instance`
      has multiple `Fields`, and each `Field` could have multiple things that need padding.
      We look at all fields in all instances, and find the max values for each (field_name,
      padding_key) pair, returning them in a dictionary.
  
      This can then be used to convert this batch into arrays of consistent length, or to set
      model parameters, etc.
      """
      padding_lengths: Dict[str, Dict[str, int]] = defaultdict(dict)
      all_instance_lengths: List[Dict[str, Dict[str, int]]] = [
          instance.get_padding_lengths() for instance in self.instances
      ]
      all_field_lengths: Dict[str, List[Dict[str, int]]] = defaultdict(
          list
      )
      for instance_lengths in all_instance_lengths:
          for (
              field_name,
              instance_field_lengths,
          ) in instance_lengths.items():
              all_field_lengths[field_name].append(
                  instance_field_lengths
              )
      for field_name, field_lengths in all_field_lengths.items():
          for padding_key in field_lengths[0].keys():
              max_value = max(
                  x.get(padding_key, 0) for x in field_lengths
              )
              padding_lengths[field_name][padding_key] = max_value
      return {**padding_lengths}
  
file_path: allennlp/allennlp/data/batch.py
imports: import logging
  from collections import defaultdict, Counter
  from typing import Dict, Iterable, Iterator, List, Union
  import numpy
  import torch
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.util import ensure_list
  from allennlp.data.instance import Instance
  from allennlp.data.vocabulary import Vocabulary
label_desc: Use image node_id 3 for calling the Batch obj's underlying member method code with example usage: obj.get_padding_lengths() and returns: dict