class_docstr: This data container generalizes the typing when instantiating pyarrow arrays, tables or batches.
  
  More specifically it adds several features:
  - Support extension types like ``datasets.features.Array2DExtensionType``:
      By default pyarrow arrays don't return extension arrays. One has to call
      ``pa.ExtensionArray.from_storage(type, pa.array(data, type.storage_type))``
      in order to get an extension array.
  - Support for ``try_type`` parameter that can be used instead of ``type``:
      When an array is transformed, we like to keep the same type as before if possible.
      For example when calling :func:`datasets.Dataset.map`, we don't want to change the type
      of each column by default.
  - Better error message when a pyarrow array overflows.
  
  Example::
  
      from datasets.features import Array2D, Array2DExtensionType, Value
      from datasets.arrow_writer import TypedSequence
      import pyarrow as pa
  
      arr = pa.array(TypedSequence([1, 2, 3], type=Value("int32")))
      assert arr.type == pa.int32()
  
      arr = pa.array(TypedSequence([1, 2, 3], try_type=Value("int32")))
      assert arr.type == pa.int32()
  
      arr = pa.array(TypedSequence(["foo", "bar"], try_type=Value("int32")))
      assert arr.type == pa.string()
  
      arr = pa.array(TypedSequence([[[1, 2, 3]]], type=Array2D((1, 3), "int64")))
      assert arr.type == Array2DExtensionType((1, 3), "int64")
  
      table = pa.Table.from_pydict({
          "image": TypedSequence([[[1, 2, 3]]], type=Array2D((1, 3), "int64"))
      })
      assert table["image"].type == Array2DExtensionType((1, 3), "int64")
class_docstr_tok: ["This","data","container","generalizes","the","typing","when","instantiating","pyarrow","arrays",",","tables","or","batches",".","More","specifically","it","adds","several","features",":","-","Support","extension","types","like","``","datasets.features.Array2DExtensionType","``",":","By","default","pyarrow","arrays","do","n't","return","extension","arrays",".","One","has","to","call","``","pa.ExtensionArray.from_storage","(","type",",","pa.array","(","data",",","type.storage_type",")",")","``","in","order","to","get","an","extension","array",".","-","Support","for","``","try_type","``","parameter","that","can","be","used","instead","of","``","type","``",":","When","an","array","is","transformed",",","we","like","to","keep","the","same","type","as","before","if","possible",".","For","example","when","calling",":","func",":","`","datasets.Dataset.map","`",",","we","do","n't","want","to","change","the","type","of","each","column","by","default",".","-","Better","error","message","when","a","pyarrow","array","overflows",".","Example",":",":","from","datasets.features","import","Array2D",",","Array2DExtensionType",",","Value","from","datasets.arrow_writer","import","TypedSequence","import","pyarrow","as","pa","arr","=","pa.array","(","TypedSequence","(","[","1",",","2",",","3","]",",","type=Value","(","``","int32","''",")",")",")","assert","arr.type","==","pa.int32","(",")","arr","=","pa.array","(","TypedSequence","(","[","1",",","2",",","3","]",",","try_type=Value","(","``","int32","''",")",")",")","assert","arr.type","==","pa.int32","(",")","arr","=","pa.array","(","TypedSequence","(","[","``","foo","''",",","``","bar","''","]",",","try_type=Value","(","``","int32","''",")",")",")","assert","arr.type","==","pa.string","(",")","arr","=","pa.array","(","TypedSequence","(","[","[","[","1",",","2",",","3","]","]","]",",","type=Array2D","(","(","1",",","3",")",",","``","int64","''",")",")",")","assert","arr.type","==","Array2DExtensionType","(","(","1",",","3",")",",","``","int64","''",")","table","=","pa.Table.from_pydict","(","{","``","image","''",":","TypedSequence","(","[","[","[","1",",","2",",","3","]","]","]",",","type=Array2D","(","(","1",",","3",")",",","``","int64","''",")",")","}",")","assert","table","[","``","image","''","]",".type","==","Array2DExtensionType","(","(","1",",","3",")",",","``","int64","''",")"]
docstr: Return the inferred feature type.
  This is done by converting the sequence to an Arrow array, and getting the corresponding
  feature type.
  
  Since building the Arrow array can be expensive, the value of the inferred type is cached
  as soon as pa.array is called on the typed sequence.
  
  Returns:
      FeatureType: inferred feature type of the sequence.
docstr_tok: ["Return","the","inferred","feature","type",".","This","is","done","by","converting","the","sequence","to","an","Arrow","array",",","and","getting","the","corresponding","feature","type",".","Since","building","the","Arrow","array","can","be","expensive",",","the","value","of","the","inferred","type","is","cached","as","soon","as","pa.array","is","called","on","the","typed","sequence",".","Returns",":","FeatureType",":","inferred","feature","type","of","the","sequence","."]
code: def get_inferred_type(self) -> FeatureType:
      """Return the inferred feature type.
      This is done by converting the sequence to an Arrow array, and getting the corresponding
      feature type.
  
      Since building the Arrow array can be expensive, the value of the inferred type is cached
      as soon as pa.array is called on the typed sequence.
  
      Returns:
          FeatureType: inferred feature type of the sequence.
      """
      if self._inferred_type is None:
          self._inferred_type = generate_from_arrow_type(
              pa.array(self).type
          )
      return self._inferred_type
  
imports: import errno
  import json
  import os
  import sys
  from pathlib import Path
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
  import fsspec
  import numpy
  import pyarrow
  import pyarrow.parquet
  from .None import config
  from .features import Features, Image, Value
  from .features.features import FeatureType, _ArrayXDExtensionType, cast_to_python_objects, generate_from_arrow_type, get_nested_type, list_of_np_array_to_pyarrow_listarray, numpy_to_pyarrow_listarray, to_pyarrow_listarray
  from .filesystems import is_remote_filesystem
  from .info import DatasetInfo
  from .keyhash import DuplicatedKeysError, KeyHasher
  from .table import array_cast, array_concat, cast_array_to_feature, embed_table_storage, table_cast
  from .utils import logging
  from .utils import tqdm
  from .utils.file_utils import hash_url_to_filename
  from .utils.py_utils import asdict, first_non_null_value
label_desc: Use image node_id 2 for calling the TypedSequence obj's underlying member method code with example usage: obj.get_inferred_type() and returns: self