code: def data_length(data: _Data) -> int:
      """
      Calculate length of data input.
  
      Accepts np.ndarray, torch.tensor, dictionary, or list. Recursively traverses the tree to find
      the first np.ndarray or torch.Tensor and calculates the length of it. Assumes that every "leaf"
      of the data structure is batched to the same length.
      """
      if isinstance(data, (np.ndarray, torch.Tensor)):
          return len(data)
      if isinstance(data, dict):
          if len(data) == 0:
              raise ValueError(
                  "`PyTorchTrial` must have at least one `np.ndarray` or `torch.Tensor` in it's dict "
                  "of inputs."
              )
          return len(next(iter(data.values())))
      if isinstance(data, list):
          if len(data) == 0:
              raise ValueError(
                  "`PyTorchTrial` must have at least one `np.ndarray` or `torch.Tensor` in it's list "
                  "of inputs."
              )
          return len(data[0])
      if isinstance(data, tuple):
          if len(data) == 0:
              raise ValueError(
                  "`PyTorchTrial` must have at least one `np.ndarray` or `torch.Tensor` in it's tuple"
                  " of inputs."
              )
          return len(data[0])
      raise TypeError("Data of incorrect type: {}".format(type(data)))
  
file_path: determined/harness/determined/pytorch/_data.py
imports: import logging
  from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Type, TypeVar, Union, cast
  import numpy
  import torch
  from packaging import version
  from torch.utils.data import BatchSampler, Dataset, RandomSampler, Sampler, SequentialSampler, _utils
  from determined.pytorch import samplers
label_desc: Use image node_id 3 for calling a global function with example usage: data_length(data) and returns: len, len, len, len