class_docstr: TODO(klausg): documentation.
class_docstr_tok: ["TODO","(","klausg",")",":","documentation","."]
docstr: Create an instance of an asset by a given id.
  
  Performs the following steps
  1. check if asset_id is found in manifest and retrieve entry
  2. determine Asset class and full path (can be remote or local cache or missing)
  3. if path is not none, then fetch and unpack the zipped asset to scratch_dir
  4. construct kwargs from asset_entry->kwargs, override with **kwargs and then
  adjust paths (ones that start with “{{asset_dir}}”
  5. create asset by calling constructor with kwargs
  6. set metadata (if add_metadata is True)
  7. return asset
  
  Args:
      asset_id (str): the id of the asset to be created
                      (corresponds to its key in the manifest file and
                      typically also to the filename)
      add_metadata (bool): whether to add the metadata from the asset to the instance
      **kwargs: additional kwargs to be passed to the asset constructor
  
  Returns:
    An instance of the specified asset (subtype of kubric.core.Asset)
docstr_tok: ["Create","an","instance","of","an","asset","by","a","given","id",".","Performs","the","following","steps","1.","check","if","asset_id","is","found","in","manifest","and","retrieve","entry","2.","determine","Asset","class","and","full","path","(","can","be","remote","or","local","cache","or","missing",")","3.","if","path","is","not","none",",","then","fetch","and","unpack","the","zipped","asset","to","scratch_dir","4.","construct","kwargs","from","asset_entry-",">","kwargs",",","override","with","*","*","kwargs","and","then","adjust","paths","(","ones","that","start","with","\u201c","{","{","asset_dir","}","}","\u201d","5.","create","asset","by","calling","constructor","with","kwargs","6.","set","metadata","(","if","add_metadata","is","True",")","7.","return","asset","Args",":","asset_id","(","str",")",":","the","id","of","the","asset","to","be","created","(","corresponds","to","its","key","in","the","manifest","file","and","typically","also","to","the","filename",")","add_metadata","(","bool",")",":","whether","to","add","the","metadata","from","the","asset","to","the","instance","*","*","kwargs",":","additional","kwargs","to","be","passed","to","the","asset","constructor","Returns",":","An","instance","of","the","specified","asset","(","subtype","of","kubric.core.Asset",")"]
code: def create(
      self, asset_id: str, add_metadata: bool = True, **kwargs
  ) -> Type[core.Asset]:
      """
      Create an instance of an asset by a given id.
  
      Performs the following steps
      1. check if asset_id is found in manifest and retrieve entry
      2. determine Asset class and full path (can be remote or local cache or missing)
      3. if path is not none, then fetch and unpack the zipped asset to scratch_dir
      4. construct kwargs from asset_entry->kwargs, override with **kwargs and then
      adjust paths (ones that start with “{{asset_dir}}”
      5. create asset by calling constructor with kwargs
      6. set metadata (if add_metadata is True)
      7. return asset
  
      Args:
          asset_id (str): the id of the asset to be created
                          (corresponds to its key in the manifest file and
                          typically also to the filename)
          add_metadata (bool): whether to add the metadata from the asset to the instance
          **kwargs: additional kwargs to be passed to the asset constructor
  
      Returns:
        An instance of the specified asset (subtype of kubric.core.Asset)
      """
      # find corresponding asset entry
      asset_entry = self._assets.get(asset_id)
      if not asset_entry:
          close_matches = difflib.get_close_matches(
              asset_id, possibilities=self.all_asset_ids, n=1
          )
          if close_matches:
              raise KeyError(
                  f"Unknown asset with id='{asset_id}'. Did you mean '{close_matches[0]}'?"
              )
  
      # determine type and path
      asset_type = self._resolve_asset_type(asset_entry["asset_type"])
      asset_path = self._resolve_asset_path(
          asset_entry.get("path", ""), asset_id
      )
  
      # fetch and unpack tar.gz file if necessary
      asset_dir = (
          None
          if asset_path is None
          else self.fetch(asset_path, asset_id)
      )
  
      # construct kwargs
      asset_kwargs = asset_entry.get("kwargs", {})
      asset_kwargs.update(kwargs)
      asset_kwargs = self._adjust_paths(asset_kwargs, asset_dir)
      if asset_type == core.FileBasedObject:
          asset_kwargs["asset_id"] = asset_id
      # create the asset
      asset = asset_type(**asset_kwargs)
      # set the metadata
      if add_metadata:
          asset.metadata.update(asset_entry.get("metadata", {}))
  
      return asset
  
imports: import difflib
  import functools
  import logging
  import pathlib
  import shutil
  import tarfile
  import tempfile
  import numpy
  import tensorflow
  from typing import Optional, Dict, Any, Type
  import weakref
  from kubric import core
  from kubric import file_io
  from kubric.kubric_typing import PathLike
label_desc: Use image node_id 12 for calling the AssetSource obj's underlying member method code with example usage: obj.create(asset_id, add_metadata) and returns: asset