license import * as tf from '@tensorflow/tfjs-core' ; import { deepMap , DeepMapResult , isIterable } from './deep_map' ; export function deepClone < T > ( container ) { return deepMap ( container , cloneIfTensor ) ; } function cloneIfTensor ( item ) { if ( item instanceof tf . Tensor ) { return ( { value : item . clone ( ) , recurse : false } ) ; } else if ( isIterable ( item ) ) { return { value : null , recurse : true } ; } else { return { value : item , recurse : false } ; } }